Loop through widgets in View and disable all buttons

Put your problem here if it does not fit any of the other categories.

Loop through widgets in View and disable all buttons

Postby twan » Thu Oct 08, 2009 4:03 pm

Good afternoon,

I have a many activities with many different widgets, from textviews to buttons. Most of these activities save entered data to a server.

While the data is transfering the user may not press a button.

One solution i found is a non general one: put all buttons that need to be disabled in button array and loop through that array and disable/enable the buttons.

Problem here is i have to define such button array for all activities and when i add a button in layout xml in also need to add the new button to the array. This can become a bit boring.

When using swing i just put up a glasspane in front of the window. But android doesn't know such a thing. So i was wondering if i can loop through the widgets defined in the layout xml.

findViewById returns a object (a widget) but i was looking for something like getviewcount() and getchildview(int index). This way i could loop through the widgets, see if they are a button and disable/enable.

But i couldn't find such functions :cry: Is there maybe something i overlooked or is there another way to accomplish this?
twan
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Oct 08, 2009 3:52 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 20 guests