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

Search This thread

arpitkh96

Senior Member
Feb 17, 2012
1,156
645
27
panipat
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:

thenobol

Senior Member
Nov 22, 2013
174
135
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
 
  • Like
Reactions: arpitkh96

arpitkh96

Senior Member
Feb 17, 2012
1,156
645
27
panipat
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
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    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