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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:54:01+00:00 2026-05-31T21:54:01+00:00

I have one SubjectTabActivity and i need to show listview on this activity. But

  • 0

I have one “SubjectTabActivity” and i need to show listview on this activity.
But when i want to implement ListActivity it doesn’t show listActivity.
I have two(addchapter,addsubject) xml file with “SubjectTabActivity”. and i need to
show my database item il list view in respective xml file. but i don’t understand
how to do that?
How to add Listactivity in TabActivity?.
Please give me any reference or code.
Thanks in advance..
Here is my reference code.

public class MasterMainActivity extends TabActivity 
{
LayoutInflater layoutInflater = null;

@Override
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.master);
     Intent intent=getIntent();
     setResult(RESULT_OK, intent);
        layoutInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        TabHost tabHost = getTabHost();


        TabHost.TabSpec tab1spec = tabHost.newTabSpec("tabOneSpec");        
        ImageView imgView = new ImageView(this);
        imgView.setBackgroundResource(R.drawable.subject);
        tab1spec.setIndicator("Subject", imgView.getBackground());
        tab1spec.setContent(new TabContentLayout());

        TabHost.TabSpec tab2spec = tabHost.newTabSpec("tabTwoSpec");
        tab2spec.setContent(new TabContentLayout());
        ImageView imgView1 = new ImageView(this);
        imgView1.setBackgroundResource(R.drawable.chapter);
        tab2spec.setIndicator("Chapter", imgView1.getBackground());   
        tabHost.addTab(tab1spec);
        tabHost.addTab(tab2spec);          
      }
            private class TabContentLayout implements TabHost.TabContentFactory {
        @Override
        public View createTabContent(String tag) {
            View view = null;
            if(tag.equals("tabOneSpec"))
            {
                try
                {
                    //static final String[] FRUITS = new String[] { "Apple", "Avocado", "Banana",
                    //  "Blueberry", "Coconut", "Durian", "Guava", "Kiwifruit",
                        //"Jackfruit", "Mango", "Olive", "Pear", "Sugar-apple" };

                    view = (LinearLayout) layoutInflater.inflate(R.layout.subjecttabview, null);
                    //setListAdapter(new ArrayAdapter<String>(this, R.layout.subjecttabview,FRUITS));

                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }                   

            }
            if(tag.equals("tabTwoSpec"))
            {
                try
                {

                    view = (LinearLayout) layoutInflater.inflate(R.layout.chaptertabview, null);    

                }
                catch(Exception e)
                {
                    e.printStackTrace();
                }
            }               
            return view;
        }
    }

How to add ListActivity in this TabActivity

  • 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-31T21:54:03+00:00Added an answer on May 31, 2026 at 9:54 pm

    Often times when creating an activity with tabs,
    it’s easy to have a separate activity for the tab content.
    However, things get tricky when those activities need to
    interact with one another.

    So the solution is to create a tabactivity with views
    (instead of activities) as the tab content.
    To create the TAB, there are a few steps we need to follow:

    1. create the tabHost and set its parameters
    2. create the tabWidget, the container for the clickable tabs
    3. create a frameLayout, to hold the views associated to each tab
    4. create each tab, using the tabSpec class

    and see these links , would help you

    http://joshclemm.com/blog/?p=59

    and

    http://www.edumobile.org/android/android-beginner-tutorials/tab-control/

    and

    http://www.pocketmagic.net/?p=1132

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

Sidebar

Related Questions

I have one server but two directories for example: www Directory1 index.php page1.php page2.php
I have one table with 20 columns, I want only display this data on
I have one XML request which I need to modify (to XML) and then
I have one drop down list in my page, which contains two options. What
I have one main form, and i want to dynamically change it's content, via
I have one solution in VS2010 containing two MVC 3 projects. These are two
I have one field that I need to sum lets say named items However
Have one application in SVN (on unfuddle.com). Want to add a new application (related
have one problem, I need the dates in Swedish format, for instance, october is
I have one testing module that I want to use for android testing. I

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.