Why can't you do something like this: public class A extends Activity { private RadiotButton _radio1;
protected void onCreate(Bundle bundle) { setContentView(your.layout.id) _radio1 = findViewById(R.id.RadioButton01); } public void doSomethingLater() { //Do something here with the radio button... _radio1.setChecked(true); } } Thanks, Justin Anderson MagouyaWare Developer http://sites.google.com/site/magouyaware On Mon, Mar 19, 2012 at 8:19 PM, Bozzified <bozi...@gmail.com> wrote: > Sorry if it's a rudimentary question about Java as I'm coming from AS3 and > just basically starting out. Though I understand many concepts so far and > am writing my first app I'm trying to find best practices in some cases. > > My question is the following. > > In AS3, I could I address an instance of a class with the string. > > So in AS3, I could do this: > > var myMC = new MovieClip(); > > myMC.name = "somename"; > > > now in my other code I can do this > > var tmpInstance = this.getChildByName("somename"); > > > > Is there an equivalent like this in Java/Android dev? > > So for a super simple example.. I'm writing a code now that looks like > this: > > RadioButton myRadioBttn1 = findViewById(R.id.RadioButton01); > RadioButton myRadioBttn2 = findViewById(R.id.RadioButton01); > > > but later in the or in my custom methods I want to do something like this: > > RadioButton myRadioBttn1_instance = this.getRadioButton("myRadioBttn1"); > > where i"m really just coming out with my own syntax here to get my point > across. So I am trying to address a specific instance of the class I > defined earlier in the code by passing a specific string so I can do > something dynamically in the code. > > I am sure I'm looking at this completely the wrong way as it is not done > like that (I'm sure that it's a bad practices because in my example I'm > creating a new instance rather than working on the existing one) but I'm > not sure how to do this dynamically. > > Thanks. > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en