Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6674095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:42:20+00:00 2026-05-26T03:42:20+00:00

i have TabActivity in android project which contains some tabs. In each tab i

  • 0

i have TabActivity in android project which contains some tabs. In each tab i can open various activities, and after open it in a tab i want go back to previous activity in same tab, but default android behavior close my root tab activity. How i can realise behavior that i need?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T03:42:21+00:00Added an answer on May 26, 2026 at 3:42 am

    There are a few ways of doing this. The first involves creating a custom GroupActivity that will keep track of the stack from the LocalActivityManager and then extending that class for each of your tabs. For that, check out this tutorial:

    http://ericharlow.blogspot.com/2010/09/experience-multiple-android-activities.html

    A simpler approach is to keep an array of your tab’s subviews within your initial ActivityGroup class and then override the back button. Here’s some sample code:

    public void replaceContentView(String id, Intent newIntent) {
        View view = getLocalActivityManager()
                        .startActivity(id, newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)) 
                        .getDecorView();
        viewList.add(view); // Add id to keep track of stack.
        this.setContentView(view);
    }       
    
    
    public void previousView() {
    
        if(viewList.size() > 0) {  
            viewList.remove(viewList.size()-1);
            if (viewList.size() > 0)
                setContentView(viewList.get(viewList.size()-1)); 
            else
              initView();
        }else {  
            finish();  
        }  
    }
    

    The initView() class holds all of the inflating of the original activity’s view. This way, you can call this method to regenerate the original activity if there are no more views in the array.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In android, I have a TabActivity with 2 tabs and each tab has it
So, in my program i have a TabActivity which contains two tabs, one tab
Here's the problem. In my app, I have 5 tabs which contains activities. In
I have an Android application which has four tabs (I use a main TabActivity
In android I have an TabActivity (A) in which I create a single tab
I have a tabactivity with several tabs. Each tab has an ActivityGroup associated with
I have a library project, which is a TabActivity, and redefined some styles to
My main activity is a TabActivity. I have some activities presented by the tab
I have a TabActivity with three tabs defined. The first tab is light-weight and
I have an android activity in which I'm using tabs. public class UnitActivity extends

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.