Looping thru interface elements

by gimpsta » Thu, 03 Sep 2009 09:23:11 GMT


Sponsored Links
 This is probably a very "newbie" question as i'm relatively new to the
android sdk, but figured this would be good place to ask.

Say you have a layout with several textviews that all have sequential
IDs (ie, tBox1, tBox2, tBox3, etc).  Is it possible to reference each
box in a loop?  Something like:

do {
iCount++;
View tvBox1 = findViewById(R.id.tBox[iCount]);
}
while (iCount < 10);


--~--~---------~--~----~------------~-------~--~----~



Looping thru interface elements

by Mark Murphy » Thu, 03 Sep 2009 09:33:34 GMT


 >

You could create a static array of the IDs and iterate over the array.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
Android App Developer Books:  http://commonsware.com/books.html 



--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Looping thru interface elements

by gimpsta » Thu, 03 Sep 2009 11:05:20 GMT


 Haha I thought of that right after I posted this.  Probably what I
will end up doing for now.

Thanks!



--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Creating Text Icon in Ginger bread

Hi all,

I want to set one text icon in status bar. Actually i want to show the 
strength of the signal, which will be updated continuously. So anyone have 
any idea about it, please let me know.

-- 

2. Determining when getRecentTasks has changed

I'm trying to figure out a way for my AppWidget's onUpdate to be
triggered by a change in ActivityManager.getRecentTasks().  Right now
it's just working off AlarmManager and updating every time (regardless
of whether there were any changes), but going off ActivityManager
seems like it would provide better responsiveness and better power
usage if it is possible.  Any ideas?

-- 

3. [WTA] Pengguna Droid Pro CDMA.

4. Bikin avatar pake Androidify.. Kerennn...

5. SG Tab tdk menyimpan daya

6. UPDATE Barang Sudah Dapet: WTB Nexus One atau htc hd2 atau yg lain budget max 4 juta

7. Nokia N8