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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:22:49+00:00 2026-05-18T12:22:49+00:00

I am looking to create an Android application that uses Tabs. Requirements When a

  • 0

I am looking to create an Android application that uses Tabs.

Requirements

When a user selects a tab and gets back to the same tab, there shouldn’t be a loading period (preferably).

Each tab will contain a listview.

In one of the tabs, I will have to use subtabs.

And that’s it.

One great example I really liked (although I didn’t try the app) is http://www.usatoday.com/android/.

  • 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-18T12:22:49+00:00Added an answer on May 18, 2026 at 12:22 pm

    I just developed a tabbed application and I used the following function to create tabs in code. The function uses intents which mean when ever a tab is selected an Activity is loaded in the tab body using intent. This function is called in main activity.

    private void SetupTabs()
        {
            TabHost tabHost = getTabHost();
    
    
            TabHost.TabSpec spec;  
            Intent intent;  
    
            //*****************************
            intent = new Intent().setClass(MPaper.this, NewsList.class);        
            spec = tabHost.newTabSpec(NewsTag).setIndicator("News")
                          .setContent(intent);        
            tabHost.addTab(spec);
            //*****************************
            intent = new Intent().setClass(MPaper.this, Search.class);        
            spec = tabHost.newTabSpec(SearchTag).setIndicator("Search")
                          .setContent(intent);        
            tabHost.addTab(spec);
            //****************************
            intent = new Intent().setClass(MPaper.this, MyNewsList.class);        
            spec = tabHost.newTabSpec(MyNewsTag).setIndicator("My News")
                          .setContent(intent);        
            tabHost.addTab(spec);
            //*****************************
            intent = new Intent().setClass(MPaper.this, Extras.class);        
            spec = tabHost.newTabSpec(ExtrasTag).setIndicator("Extras")
                          .setContent(intent);        
            tabHost.addTab(spec);
            //*****************************
    
    
            tabHost.setCurrentTabByTag(NewsTag);
        }
    

    The list view in NewsList Activity is made by XML as following:

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/tabhost" 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
    
        <ListView 
            android:id="@+id/NewsList" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content"
            >
    
        </ListView>
    
    </LinearLayout>
    

    In Response to Fabios’ comment below:
    Yes wither use visibility property or try implementing tabs using the way mentioned below:

    private void TabSetup()
        {
            tabs = (TabHost)findViewById(R.id.tabhost);        
            tabs.setup(); 
            TabHost.TabSpec spec = tabs.newTabSpec("MainNewsTag");
            spec.setContent(R.id.MainNews);
            spec.setIndicator("Home");
            tabs.addTab(spec);
    
    
    
    
            spec = tabs.newTabSpec("SearchTag");
            spec.setContent(R.id.Search);
            spec.setIndicator("Search");
            tabs.addTab(spec);
    
    
            spec = tabs.newTabSpec("MyNewsTag");
            spec.setContent(R.id.MyNews);
            spec.setIndicator("My News");
            tabs.addTab(spec);
    
            spec = tabs.newTabSpec("ExtrasTag");
            spec.setContent(R.id.MyNews);
            spec.setIndicator("Extras");
            tabs.addTab(spec);
    } 
    

    Where as Layout file is as below:

        <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
            android:id="@+id/tabhost" android:layout_width="fill_parent"
            android:layout_height="fill_parent">
            <RelativeLayout android:layout_height="fill_parent"
                android:layout_width="fill_parent">
                <TableLayout android:layout_height="fill_parent" 
                   android:layout_width="fill_parent">
                   <TabWidget android:id="@android:id/tabs"
                   android:layout_height="wrap_content"
                       android:layout_width="fill_parent" />
                   <FrameLayout android:id="@android:id/tabcontent"
                        android:layout_height="wrap_content"
                                    android:layout_width="fill_parent" >  
                       <ListView android:id="@+id/MainNews" 
                                 android:layout_width="fill_parent"
                                 android:layout_height="wrap_content">
                       </ListView>
    .... and so on 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I were looking to create my own language are there any tools that
I'm a developer looking to create an Android application to record phone calls. This
For the current Android application I'm working on, I'm looking to create a tcp
I'm writing a web app that points to external links. I'm looking to create
I am trying to create a small pop-up in my Android application to let
I want to create a calendar in my application that external users can view.
I'm looking to create favicon.ico files programatically from Python, but PIL only has support
I am looking to create symlinks (soft links) from Java on a Windows Vista/
I'm looking to create an Intellij IDEA language support plugin for Erlang. The first
I am looking to create an expression tree by parsing xml using C#. The

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.