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 8481369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:32:37+00:00 2026-06-10T19:32:37+00:00

In my application I am trying to open an activity from a button in

  • 0

In my application I am trying to open an activity from a button in tab using intent. But instead of opening in the same tab the new activity covers the entire screen and the tabs are no linger visible.. How can I open more than one activity in the same tab..

The following code is of my main class:

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TabHost tabHost = getTabHost();
    tabHost.addTab(tabHost.newTabSpec("tab1").setIndicator("OPT").setContent(new Intent(this, TabGroup1Activity.class)));
    tabHost.addTab(tabHost.newTabSpec("tab2").setIndicator("EDIT").setContent(new Intent(this, TabGroup2Activity.class)));
    tabHost.setCurrentTab(1);
}

The following is the code of TabGroupActivity:

public class TabGroupActivity extends ActivityGroup{

ArrayList<String> list;
Window window;
@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);

    if(list.equals(null))
    {
        list = new ArrayList<String>();
    }
}

@Override
public void finishFromChild(Activity child)
{
    LocalActivityManager manager = getLocalActivityManager();
    int index = list.size() -1;
    if(index < 1)
    {
        finish();
        return;
    }
    manager.destroyActivity(list.get(index), true);
    list.remove(index);
    index--;
    String lastId = list.get(index);
    Intent in = manager.getActivity(lastId).getIntent();
    window = manager.startActivity(lastId, in);
    setContentView(window.getDecorView());
}

public void startChildActivity(String Id, Intent intent)
{
    window = getLocalActivityManager().startActivity(Id, intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    if(window != null)
    {
        list.add(Id);
        setContentView(window.getDecorView());
    }
}

@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
    if(keyCode == KeyEvent.KEYCODE_BACK)
        return true;
    return super.onKeyDown(keyCode, event);
}

@Override
public boolean onKeyUp(int keyCode, KeyEvent event)
{
    if(keyCode == KeyEvent.KEYCODE_BACK)
    {
        onBackPressed();
        return true;
    }
    return super.onKeyUp(keyCode, event);
}

@Override
public void onBackPressed()
{
    int length = list.size();
    if(length > 1)
    {
        Activity current = getLocalActivityManager().getActivity(list.get(length - 1));
        current.finish();
    }
}
}

The code for TabGroup1Activity the TabGroup2Activity also having the same code:

public class TabGroup1Activity extends TabGroupActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    startChildActivity("TestClass", new Intent(this,TestClass.class));
}
}

Code for the TestClass activity:

public class TestClass extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.newview);
}
}

Please help me is solving my problem..

Thanks in advance…

  • 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-06-10T19:32:39+00:00Added an answer on June 10, 2026 at 7:32 pm

    You can do it using fragments..check http://mobile.tutsplus.com/tutorials/android/android-compatibility-working-with-fragments/

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

Sidebar

Related Questions

i am trying to open camera from my android application and capture image, but
I'm trying to open the On Screen Keyboard from within a web application on
I'm new to android... having trouble trying to open a URL from a live
I am trying to open an existing message from my application so that the
I'm trying to open default browser in Android from an application's dialog with a
In my application i am trying to open a dialog box when activity started
I'm trying to open and read from a serial port using the System.IO.Ports.SerialPort class.
I am trying to use intent filter to open URLs in my application (as
I'm trying to create following autorization application for android. But after pressing login button
I'm trying to open iOS's mail application by clicking a button. So I did

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.