ActivityGroup is Deprecated

て烟熏妆下的殇ゞ 提交于 2019-12-06 02:31:44

问题


I am making android application containing three tabs.. On third tab there is login screen..

when i click on login button ...i want to replace the activity with activity containing list view and logout button....

Previously i was using Activity Group to replace the activity..But activity Group is now deprecated..

Now how can i replace the activity under third tab??

I am using these code

Intent intent = new Intent(MyApp.this, LoginPage.class);

                    replaceContentVieww("activity4", intent);



  public void replaceContentVieww(String id, Intent newIntent) {
                    // TODO Auto-generated method stub


View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); 
                            setContentView(view);


                    }

There is link from which i came to know this class has been deprecated.


回答1:


you should use Fragment and FragmentManager in the Compatibility Package

http://developer.android.com/sdk/compatibility-library.html

download it using the ADT, then go to the samples here extras/android/compatibility/v4/samples/




回答2:


Now how can i replace the activity under third tab??

You can define tab contents as existing children of the FrameLayout (via the setContent() that takes a widget ID) or as a dynamically-created View (via the setContent() that takes a TabContentFactory).



来源:https://stackoverflow.com/questions/7579721/activitygroup-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!