Post Reply Subscribe to Thread Email Thread

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

26th February 2014, 08:03 AM |#1  
arpitkh96's Avatar
OP Senior Member
Flag panipat
Thanks Meter: 571
 
1,145 posts
Join Date:Joined: Feb 2012
Donate to Me
More
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
Last edited by arpitkh96; 26th February 2014 at 09:13 AM.
26th February 2014, 11:36 AM |#2  
Senior Member
Thanks Meter: 133
 
169 posts
Join Date:Joined: 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
The Following User Says Thank You to thenobol For This Useful Post: [ View ]
26th February 2014, 02:17 PM |#3  
arpitkh96's Avatar
OP Senior Member
Flag panipat
Thanks Meter: 571
 
1,145 posts
Join Date:Joined: Feb 2012
Donate to Me
More
Quote:
Originally Posted by thenobol

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
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes