0

I have to develop back button functionality in android application.

I have 4 tabs in tabgroup activity. Here i have to create the 4th tab is Go Back.

Here i have to 4th tab means the 4 th tab is go to my previous activity.

These is my tabgroupactivity code:

intent = new Intent().setClass(this, MainGroupActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost.newTabSpec("Home").setIndicator("Home", 
                    res.getDrawable(R.drawable.arrow_up_float))
                    .setContent(intent);
    tabhost.addTab(spec);

    intent = new Intent().setClass(this, CartGroupActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost
            .newTabSpec("Cart")
            .setIndicator("Cart",
                    res.getDrawable(R.drawable.arrow_down_float))// debttab moretab
                                                        // expensestab
            .setContent(intent);
    tabhost.addTab(spec);

    intent = new Intent().setClass(this, LoginGroupActivty.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost.newTabSpec("Login").setIndicator("Login",
                   res.getDrawable(R.drawable.btn_default_small))
                   .setContent(intent);
    tabhost.addTab(spec);
    intent = new Intent().setClass(this, GoBackActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    // Initialize a TabSpec for each tab and add it to the TabHost
    spec = tabhost
            .newTabSpec("Go Back")
            .setIndicator("Go Back",
                    res.getDrawable(R.drawable.arrow_down_float))// debttab moretab
                                                        // expensestab
            .setContent(intent);
    tabhost.addTab(spec);

Here the MainGroupActivity have 2 child class...i mean the main group activity have listview .i have to click any list means it is go to 1st child activity and have displayed listview with 4 tabs(tabgroup) in next screen.now i have to click any list in 1st child means it is go to 2nd childview and have displayed listview with 4tabs(tabgroup)..now i wish to click 4th tab(go back) in 2nd childview means its go to previous activity(1st child view)..how can i do ??? please help me...

How can i write the condition for 4th tab.please give me code for these purpose.

android
  • 33
  • 3
  • 12

1 Answers1

0

you can use

Intent intent = new Intent( v.getContext(), YourOtherActivity.class);
   startActivity(intent);}

` now when the user click tab it will automatically take the user to your other activity.

Kosh
  • 6,140
  • 3
  • 36
  • 67