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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:23:10+00:00 2026-05-15T23:23:10+00:00

Here’s my problem: I’ve have an application with tabs. in each tab I have

  • 0

Here’s my problem:
I’ve have an application with tabs.
in each tab I have a list that list to an other list then to a screen with an image, clickable text etc.
In one word I have Tasks inside tabs.

Question
Despite long seek among forum and tutorials I still can’t figure witch is the best pactice to do that : switching activity insde a tab
or changing the view.

Here my code

public class App extends TabActivity {

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Reusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, Activity0.class);

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

        intent = new Intent().setClass(this, Activity1.class);
        spec = tabHost.newTabSpec("1").setIndicator("1", 
                        res.getDrawable(R.drawable.ic_tab_1))
                      .setContent(intent);
        tabHost.addTab(spec);

then I have to switch activities (Activity0 -> Activity01) inside tab 0

public class Activity0 extends Activity{
..
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainlist);
        ListView l1 = (ListView) findViewById(R.id.ListView01);

        l1.setOnItemClickListener(new OnItemClickListener() {

            public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
            long arg3) {
//          Toast.makeText(getBaseContext(), "You clciked "+parentTypes.get(arg2).getLibelle(), Toast.LENGTH_LONG).show();
            /*TODO database method */
            TypeEvenement parent = parentTypes.get(arg2);   
            if (parent.getChildren().size()!=0)
            {
                Intent i = new Intent(TypeParentList.this, TypeChildList.class);
                int id= new Long(parentTypes.get(arg2).getId()).intValue();
                i.putExtra("typeid", id);

                View view = lam.startActivity("TypeChildList",i.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP)).getDecorView(); 

                setContentView(view);

then go back to this activity from Activity01

public class Activity01 extends Activity{
        tv.setOnClickListener(new View.OnClickListener() {
              public void onClick(View view) {
                    Intent i = new Intent(TypeChildList.this, Activity0.class);
                    LocalActivityManager lam = pa.getLocalActivityManager();


                    View view2 = lam.startActivity("Activity0",i).getDecorView(); 
                    setContentView(view2);

              }
              });

After go and back I get an error java.lang.IllegalStateException The specified child already has a parent. You must call removeView() on the child’s parent first.

I know it comes from my view but I can’t figure out how to fix it
So is this the best practice to do multiple activity in one tab ?

Please help needed

  • 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-15T23:23:10+00:00Added an answer on May 15, 2026 at 11:23 pm

    If you use a ViewSwitcher or ViewFlipper you can keep the View attached to that and switch back and forth to your hearts desire.

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

Sidebar

Related Questions

Here is the problem that I am trying to solve. I have two folders
Here is my problem : I have a post controller with the action create.
Here is another spoj problem that asks how to find the number of distinct
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here's a coding problem for those that like this kind of thing. Let's see
here's the problem: In my WPF application I used to load/parse my .xaml files
Here is the Javascript I currently have <script type=text/javascript> $(function() { $('.slideshow').hover( function() {
Here's the basic setup: I have a thin bar at the top of a

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.