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. Listview with different rows (layouts)

Hey,

I want to make a listview that has different rows (layouts). I will
load the data from a webservice and it can be 2 or more layouts i have
to generate then. I am creating a social network app and want to show
a stream of the users activity.
So when he made a comment, make a new friend, this all has to come in
the same list.. I load 1 XML file with multiple different child
objects (comment, friend) so i can see which layout i have to use.

I have saw this at the Brightkite android app:

http://www.grabup.com/uploads/c278f22e9bd19a2ccac2246ebd85326c.png?direct

user checked in, posted note --> different rows..

But I don't know how to do that.. I use a custom adapter for my
listview but i only can choose one row layout for my list..

Please help me!
Thank Wouter
--~--~---------~--~----~------------~-------~--~----~

2. How to run the latest version of Android

Hi, I'm trying to do some work on the location framework, but I can't
figure out how to install and view my changes.

I've tried looking this up, but I get the impression I don't know the
right terminology.

Essentially, what I'd like to do is this:
1. Download the donut source
2. make changes to it
3. Run those changes in the emulator to test them out
4. Once the changes are proven to be good, run them in my dev phone

So far, I've gotten through downloading and making the android code,
but I can't figure out where to go from there. Can somebody give me
some advice as to how to get steps 3 and 4 working?

Thanks,

Mike

PS - I posted this on the android- beginners list, but was redirected
here. The original post was:

3. IOException while reading a raw resource.

4. Any way to transfer Android ID from App environment to Browser on Android phone

5. view.draw() at horizontal offset?

6. Very basic questions about porting and my linux based phone.

7. Loading large assets