Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,737,452 Members 42,499 Now Online
XDA Developers Android and Mobile Development Forum

[q]How to get the present layout of an activity

Tip us?
 
arpitkh96
Old
(Last edited by arpitkh96; 26th February 2014 at 09:13 AM.)
#1  
arpitkh96's Avatar
Senior Member - OP
Thanks Meter 375
Posts: 1,085
Join Date: Feb 2012
Location: panipat
Default [q]How to get the present layout of an activity

I have used a command in an onclicklistener of button to change the layout without creating a new activity like this
setContentView(R.layout.myxml);

Now to i want to override onBackPressed so that
if layout is a changed one,it will first go to default layout ,then exit the app.
But how can i identify that which layout is currently set on the activity

Sent from my GT-S5570 using XDA Premium 4 mobile app
 
thenobol
Old
#2  
Senior Member
Thanks Meter 129
Posts: 168
Join Date: Nov 2013
you could store the layouts id in a class variable and inflate the new layout via a fragment (like within the navigation drawer by google) so on the buttons onclick the layout is inflated via a fragment and within onBackPressed you could inflate the former fragment, by setting it's id!

Sent from my Nexus 5 using XDA Premium 4 mobile app
Keep Calm, and push the THANKS button
Nexus 5
The Following User Says Thank You to thenobol For This Useful Post: [ Click to Expand ]
 
arpitkh96
Old
#3  
arpitkh96's Avatar
Senior Member - OP
Thanks Meter 375
Posts: 1,085
Join Date: Feb 2012
Location: panipat
Quote:
Originally Posted by thenobol View Post
you could store the layouts id in a class variable and inflate the new layout via a fragment (like within the navigation drawer by google) so on the buttons onclick the layout is inflated via a fragment and within onBackPressed you could inflate the former fragment, by setting it's id!

Sent from my Nexus 5 using XDA Premium 4 mobile app
Thanks.i got the sol already

Sent from my GT-S5570 using XDA Premium 4 mobile app
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes