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

  • Home
  • SEARCH
  • 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 3219774
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:41:06+00:00 2026-05-17T15:41:06+00:00

package com.example.helloandroid; import java.util.ArrayList; import java.util.Arrays; import android.app.TabActivity; import android.os.Bundle; import android.view.Window; import android.widget.ArrayAdapter;

  • 0
package com.example.helloandroid;

import java.util.ArrayList;
import java.util.Arrays;

import android.app.TabActivity;
import android.os.Bundle;
import android.view.Window;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;

public class HelloAndroid extends TabActivity {
/** Called when the activity is first created. */
private ListView mainListView ;  
private ArrayAdapter<String> listAdapter ;
@Override


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

    TabHost mTabHost = getTabHost();

    mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1"));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2"));
    mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3"));

    mTabHost.setCurrentTab(0);

 // Find the ListView resource.   
    mainListView = (ListView) findViewById( R.id.lstMain);  

    // Create and populate a List of planet names.  
    String[] planets = new String[] { "Mercury", "Venus", "Earth", "Mars",  
                                      "Jupiter", "Saturn", "Uranus", "Neptune"};    
    ArrayList<String> planetList = new ArrayList<String>();  
    planetList.addAll( Arrays.asList(planets) );  

    // Create ArrayAdapter using the planet list.  
   listAdapter = new ArrayAdapter<String>(this, R.layout.main, planetList);  

    // Set the ArrayAdapter as the ListView's adapter.  
    mainListView.setAdapter( listAdapter ); 


 // End


}

}

and here is the code for my xml file.

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

  <LinearLayout
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />
    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView 
            android:id="@+id/textview1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is a tab" />
        <TextView 
            android:id="@+id/textview2"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is another tab" />
        <TextView 
            android:id="@+id/textview3"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" 
            android:text="this is a third tab" />
        <ListView
            android:id="@+id/lstMain" 
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content">

  • 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-17T15:41:07+00:00Added an answer on May 17, 2026 at 3:41 pm

    maybe if you look at two of my blog articles it might give you some helpful ideas.
    check out multiple-android-activities
    also take a look at the Configuring Android Listview article as well.
    Hope it helps.

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

Sidebar

Related Questions

02-18 00:02:08.432: ERROR/PackageManager(57): Package com.example.brown requires unavailable shared library com.google.android.maps; failing! I got this
How do I call start() below? package com.example.test; class Bar {} public class Foo<K>
This confuses me. The following compiles fine under Eclipse. package com.example.gotchas; public class GenericHelper1
If I call: java org.antlr.Tool -o outdir sources/com/example/Java5.g ...with antlr-3.1.3 the parser and lexer
I do an import of the full package name / java file, and if
Let's say I have a file called test.txt within the package com.test.io within my
Given a property: <property name=classes value=com.package.Class1,com.package.Class2 /> I'm trying to compile only the classes
So most Java resources when speaking of packages mention a com.yourcompany.project setup. However, I
What are some good package naming conventions for domain specific object models. For example,
Is there a Java package providing funcionality like the .Net System.Data namespace ? Specificaly

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.