5

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.

Gopesh Gupta
  • 707
  • 8
  • 19

2 Answers2

4

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/

Mahdi Hijazi
  • 4,424
  • 3
  • 24
  • 29
  • how can i use it in my app? There is any sample code to do it – Gopesh Gupta Sep 28 '11 at 07:42
  • I have put the samples path in my answer, for more information on fragments please refer to http://developer.android.com/guide/topics/fundamentals/fragments.html – Mahdi Hijazi Sep 28 '11 at 08:01
  • It's not a link for sample . Can you give me complete link for this – Gopesh Gupta Sep 28 '11 at 08:03
  • it is not a link, it is a path on your pc, if you downloaded the Compatibility Package, go to your android sdk directory and from there go to "extras/android/compatibility/v4/samples/" – Mahdi Hijazi Sep 28 '11 at 08:07
  • i have downloaded the package, but the sample code not working in eclipse .. there is any method. – Gopesh Gupta Sep 28 '11 at 08:44
  • Right click your project in eclipse, then choose Add Compatibility library, now you should see android-support-v4.jar under the referenced libraries. – Mahdi Hijazi Sep 28 '11 at 08:53
0

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).

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • there are two views i.e. one is login view and after login, there is list view . How can i set the view and on button click , how will i call the second view by replacing the view.... – Gopesh Gupta Sep 28 '11 at 13:16