FORUMS

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

1,149 posts
Thanks Meter: 581
 
By arpitkh96, Senior Member on 26th February 2014, 08:03 AM
Post Reply Subscribe to Thread Email Thread
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
 
More
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: 581
 
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