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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:09:13+00:00 2026-05-27T17:09:13+00:00

I am working on an application that pulls information from the internet. The information

  • 0

I am working on an application that pulls information from the internet. The information is sorted into categories, sub-categories and, sub-sub-categories.

My main view is a TabHost view (the parent categories) with 3 tabs, and the initial list view (the sub-categories). When the user clicks an item in the list view it calls a new list view that displays the child-categories of the chosen sub-category.

I got everything to work except that when a sub category is chosen the tabHost view disappears and the sub-sub-categories are displayed in full screen.

How can I change the intent of the tab to display the child-categories of the sub-category?

EDIT: here is my code, sorry I didn’t post it earlier!

My Main view which contains the tabhost:

public class tabwidget  extends TabActivity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabs);

    Resources res = getResources(); // Resource object to get Drawables
    TabHost tabHost = getTabHost();  // The activity TabHost
    TabHost.TabSpec spec;  // Resusable 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, category1Activity.class);

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

    // Do the same for the other tabs
    intent = new Intent().setClass(this, category2Activity.class);
    spec = tabHost.newTabSpec("category2").setIndicator("Category2",
                      res.getDrawable(R.drawable.ic_tab_category2))
                  .setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, category3Activity.class);
    spec = tabHost.newTabSpec("category3").setIndicator("Category3",
                      res.getDrawable(R.drawable.ic_tab_category3))
                  .setContent(intent);
    tabHost.addTab(spec);


    tabHost.setCurrentTab(0);
}

When the application is started the alcohol tab is selected by default. This is the category1Acitivity listview with the onlclick action that calls the child-categories:

listView.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {              
          //Toast.makeText(getApplicationContext(), "You clicked item at position"+position,
          //Toast.LENGTH_SHORT).show();

            Toast.makeText(getApplicationContext(), "Loading "+((TextView) view.findViewById(R.id.categoryname)).getText(),
            Toast.LENGTH_SHORT).show();

            Intent i = new Intent(category1Activity.this, subCategoryActivity.class);
            i.putExtra("id", ((TextView) view.findViewById(R.id.message)).getText());
            i.putExtra("catname", ((TextView) view.findViewById(R.id.categoryname)).getText());
            i.putExtra("parentcatid", "0");
            startActivityForResult(i, ACTIVITY_CREATE);




        }
    });

The listviews are generated by the category Id which is sent to the server pulls results from the database.

  • 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-27T17:09:14+00:00Added an answer on May 27, 2026 at 5:09 pm

    You will have to use ActivityGroups to do that.

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

    http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

    However, keep in mind that ActivityGroups are deprecated in ICS.

    EDIT: This is my implementation of ActivityGroup:

    Activity in a tab:

    Intent i = new Intent(v.getContext(), SearchList.class);
    i.putExtra("search", search);
    
    View view = SearchActivityGroup.group.getLocalActivityManager()  
    .startActivity("SearchList", i  
    .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))  
    .getDecorView();  
    
    // Again, replace the view  
    SearchActivityGroup.group.replaceView(view);
    

    ActivityGroup:

    package nl.dante.SuperDeals;
    
    import java.util.ArrayList;
    
    import android.app.ActivityGroup;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.View;
    
    public class SearchActivityGroup extends ActivityGroup {
    
    View rootView;
    
    // Keep this in a static variable to make it accessible for all the nested
    // activities, lets them manipulate the view
    public static SearchActivityGroup group;
    
    // Need to keep track of the history if you want the back-button to work
    // properly, don't use this if your activities requires a lot of memory.
    private ArrayList<View> history;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /*
         * this.history = new ArrayList<View>(); group = this;
         * 
         * // Start the root activity within the group and get its view View
         * view = getLocalActivityManager().startActivity("Search", new
         * Intent(this,Search.class) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
         * .getDecorView();
         * 
         * // Replace the view of this ActivityGroup replaceView(view);
         */
    
    }
    
    @Override
    protected void onResume() {
    
        super.onResume();
        this.history = new ArrayList<View>();
        group = this;
    
        // Start the root activity within the group and get its view
        View view = getLocalActivityManager().startActivity("Search", new Intent(this, Search.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
    
        // Replace the view of this ActivityGroup
        replaceView(view);
    }
    
    public void replaceView(View v) {
        // Adds the old one to history
        if (history.size() == 0) {
            if (rootView != null) {
                history.add(rootView);
                rootView = null;
            }
        }
        history.add(v);
        // Changes this Groups View to the new View.
        setContentView(v);
    }
    
    public void back() {
        try {
            if (history.size() > 0) {
                if (history.size() == 1) {
                    rootView = history.get(0);
                    Toasts.ToastImageView(this, "Druk nogmaals BACK om af te sluiten", R.drawable.power_64_off, "red");
                }
                history.remove(history.size() - 1);
                setContentView(history.get(history.size() - 1));
            } else {
                finish();
            }
            if (history.size() < 3) {
                // Tabhost.bannerImage2.setImageResource(0);
                Tabhost.banner.setBackgroundResource(R.drawable.gradient_blue);
            }
            if (history.size() == 2) {
                Tabhost.bannerImage1.setImageResource(R.drawable.sorteer_btn);
            }
        } catch (Exception ex) {
        }
    }
    
    public int getHistorySize() {
        return history.size();
    }
    
    @Override
    public void onBackPressed() {
        try {
            SearchActivityGroup.group.back();
        } catch (Exception ex) {
    
        }
        return;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a backend Grails application that pulls information periodically from a
I am currently working on an application that pulls Google Map locations from an
Im working with a flex application that pulls data from a java class file
I'm working on an AJAX application that pulls data from a live website, I
We're working on an application that displays information through a Direct3D visualisation. A late
Scenario: I have an application that pulls data from a SQL database as well
I have been working on creating an application that sends a string from an
I'm writing an application updater that pulls installation package from our distribution web site
I'm working on an application that will need to pull from a list of
I'm working on a PHP application that needs to obtain data from a topographical

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.