Can i possibly get the layout of my activity when back key was pressed? or something that could identify the contentView of that Activity?
Asked
Active
Viewed 181 times
0
-
1Why are you trying to do this? Why would you need the View, when the UI is no longer shown – Raghav Sood Feb 15 '13 at 13:43
-
http://stackoverflow.com/questions/5273436/how-to-get-activitys-content-view Use this in your `onBackPressed()` method. – M-Wajeeh Feb 15 '13 at 13:43
-
its because, i dont use intents, i only setcontentview everytime i have done something. – ロン 産 Feb 15 '13 at 14:27
2 Answers
2
((ViewGroup)findViewById(android.R.id.content)).getChildAt(0)
This should return you the Root View of current activity

Klawikowski
- 605
- 3
- 11
0
Add id to your parent view of layout and then get the reference by using findViewById() providing the id of the parent view.

Khawar Raza
- 15,870
- 24
- 70
- 127