Determining the current content view

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Determining the current content view

Postby BGH » Tue Oct 06, 2009 5:49 am

I call setContentView multiple times in my activity to change the layout currently displayed on screen. Is there a way to programatically test the activity to test which layout is currently the one displayed on screen or should I just maintain a variable myself that contains which layout it is?
User avatar
BGH
Junior Developer
Junior Developer
 
Posts: 23
Joined: Thu Feb 12, 2009 3:51 am
Location: Melbourne, Australia

Top

Postby PaulFake » Tue Oct 06, 2009 9:08 am

I've searched for that before and never found anything. If you just want to get the current content as a way to manage the state of your activity, you might as well just store the current state in memory as a nicely-named static integer. That'll at least make your code more readable, for what it's worth.
PaulFake
Junior Developer
Junior Developer
 
Posts: 21
Joined: Wed Aug 26, 2009 1:05 am

Postby Sowmya » Tue Oct 06, 2009 12:18 pm

Hi,
You can check for null using findViewById(R.id.buttonTest)..If buttonTest widget is not found in the current view (ie set using setContentView(...) method ) it will return null...Hope this helps..
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Postby wiederke » Tue Oct 06, 2009 8:38 pm

Hi,

I suggest using a different activity for each layout. If you change the layout you normally change the funtionality, so you should change to a different activity.


Bye,

Torsten
wiederke
Experienced Developer
Experienced Developer
 
Posts: 72
Joined: Mon Mar 02, 2009 6:46 pm
Location: Germany

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 4 guests