how to get Activity View inside that activity?
I want to show my next activity withing my previous activity layout "LinearLyout". But it is not working. Can any one help?
I put my last activity layout reference to a global class in an static variable. My code in next activity is as follow
public onCreate(){
View view = findViewById(R.layout.topstory_detail_layout); setContentView(view); // My code
Global.mainActity.contentViewLayout.removeAllViews(); Global.mainActity.contentViewLayout.addView(this.getWindow().getDecorView());
Here is exception
11-11 11:41:07.330: ERROR/AndroidRuntime(559): Uncaught handler: thread main exiting due to uncaught exception 11-11 11:41:07.460: ERROR/AndroidRuntime(开发者_如何学运维559): java.lang.RuntimeException: view com.android.internal.policy.impl.PhoneWindow$DecorView@44c3cc70 being added, but it already has a parent 11-11 11:41:07.460: ERROR/AndroidRuntime(559): at android.view.View.assignParent(View.java:5721)
Can you explain it better what is global an activity?
btw if i understand you want do create an activity group that contains an activity http://developer.android.com/reference/android/app/ActivityGroup.html
and you can read what is here
http://www.mail-archive.com/android-developers@googlegroups.com/msg37528.html
Don't store anything context-related in global static variables, this leads to memory leaks.
Maybe you should just perform the start your second ativity with FLAG_ACTIVITY_CLEAR_TOP flag. In this case, the new activity will substitute the first one.
Also you can call current activity's finish() just after the startActivity().
Finally, you might want to use the ViewFlipper to change Activity's view.
精彩评论