[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-29 Thread Glen Humphrey
I found that if you do something like this it works almost identically to the magic number method. ListView android:id=@+id/your_list android:layout_width=fill_parent android:layout_height=wrap_content /ListView protected Dialog

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Brian
Yes, that did work, thanks much. What does that magic number represent? On Mar 28, 2:54 am, Glen Humphrey glendon.humphr...@gmail.com wrote: I also had to do one of the following to get it to work correctly.     if (!lv.isItemChecked(0)) {         lv.setItemChecked(0, true);     } or  

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Glen Humphrey
Every view in Android has an id number assigned to it. When you put android.R.id.button1 for example that is a constant that defines the number 16908313. The number 16908667 does not seem to have a constant defined for it in the SDK. This means that this number could be possibly be changed in a

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Brian
Ya, so how did you conjure up 16908667? In trying to debug this, I looked at the various android.R.id.* values to see if I could see something else that makes sense, but didn't see anything. If 16908667 is undocumented, where did you find it? By spelunking through the source? Thanks. On Mar

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Brian
Excellent -- I have the same value for mlistView's mId in the onPrepareDialog(). fwiw, I'm not casting to an AlertDialog, just the ListView: ListView lv = (ListView) d.findViewById(16908667); Pretty hacky, I'm not sure I want to ship this magic number, but that's a ways off. I'm new to Android

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Mark Murphy
Brian wrote: I'm new to Android dev but not device dev itself, and know things can get a bit on-the-edge. Is this a fairly common way to make an Android app -- set breakpoints, drill through structures, and use IDs you find there? Using debuggers to try to reverse engineer magic numbers at

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Mark Murphy
Brian wrote: Radio buttons are more appropriate in this case than a checkbox, but yeah, basically the same idea. Sorry -- I was dealing with a headache when I wrote that... ;-) It's actually good to hear the Android way doesn't include hacking around IDs -- but at the same time, wish it was

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Mark Murphy
Brian wrote: I'm setting an individual RadioButton. Is that the right way to select? That should work. There's a corresponding method on RadioGroup. I have no idea if inflating from xml is the best way to instantiate a view, it's just what popped in mind. It's perfectly fine. You'll do

[android-beginners] Re: Setting Single Choice Dialog Checked Item

2009-03-28 Thread Brian
Ok, selecting through the radiogroup works. I was expecting a setChecked method, and just missed checked. Final version of onPrepareDialog(): RadioGroup rg = (RadioGroup) dialog.findViewById (R.id.savecancelgroup); rg.check(R.id.save); Thanks for the help. P.S. Using 16908667 was more fun...