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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T05:57:06+00:00 2026-06-04T05:57:06+00:00

I want to create something like this |Button| item 1 item 2 item 3

  • 0

I want to create something like this

|Button|

item 1

item 2

item 3

.
.
.Items on a listview

I already have a tabhost with 3 tabs, so i don’t want to change my main.xml because the button will appear on every tab! i want my first tab to show a calendar (this one is done, i’m not sure if its ok but it has be done), the second tab will show something diferrent and the last one the button and the item list underneath.

I donnot paste any code because everything i’ve done comes from android tutorials, so i don’t want to ask someone to give me an already written code, just to guide me through what do i have to read and where to look to achieve that!

Thanks in advance!

Well this is what I’ve done so far
this is my main class

`public class HourPayActivity 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;  // Resusable TabSpec for each tab
    Intent intent;  // Reusable Intent for each tab

    // Create an Intent to launch an //setContentView(R.layout.emptab); Activity for the tab (to be reused)
    intent = new Intent().setClass(this, MonthsActivity.class);

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

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

    intent = new Intent().setClass(this, PaymentsActivity.class);
    spec = tabHost.newTabSpec("Payments").setIndicator("",
                      res.getDrawable(R.drawable.ic_tab_payments))
                  .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);
}

}
`

And this is the tab content that i want to show up

public class EmployersActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);


    ListView employersList = getListView();

    String[] employers = getResources().getStringArray(R.array.employers_list);
    setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, employers));
    employersList.setAdapter(getListAdapter());       

    employersList.setTextFilterEnabled(true);



    employersList.setOnItemClickListener(new OnItemClickListener() {
        //@Override
        public void onItemClick(AdapterView<?> parent, View view,
            int position, long id) {
          // When clicked, show a toast with the TextView text
          Toast.makeText(getApplicationContext(), ((TextView) view).getText(),
              Toast.LENGTH_LONG).show();
        }
    });

    setContentView(employersList);

}
  • 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-06-04T05:57:07+00:00Added an answer on June 4, 2026 at 5:57 am

    What you do is; You follow the android tutorial, which tells you to create an class that extends TabActivity if I remember correctly.

    In this activity you load intents via

    TabHost.TabSpec spec = tabHost.newTabSpec([title]);
    ....
    Intent content = new Intent(this, activityToLoad.class);
    spec.setContent(content);
    tabHost.addTab(spec);
    

    What this does is, it loads an activity in a tab.
    This in turn means that you can use an activity like normal, you can use custom layouts with setContentView(R.layout.yourlayout); in the onCreate() method. You can call your components, attach a custom list adapter to your list and so on. For the 3 tabs create 3 different activities. Based on personal knowledge its the easiest way to maintain your tabs.

    What you put in these layout is upto you. But those activities you put in the tabs are “normal” activities like you are (probably) familiar with.

    To explain your view:

     <LinearLayout
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
     android:layout_height="match_parent">
        <Button 
         android:id="@+id/btnId"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:text="@string/yourtext"
         />
        <ListView 
        android:id="@android:id/android:list"
        android:layout_height="fill_content" 
        android:layout_width="match_parent"
        />
    </LinearLayout>
    

    This will place a button at the top with a listview underneath it.
    The id of the listview is android:list because in my activity i extend listActivity, which expects a listview with that id.

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

Sidebar

Related Questions

I want to do something like this create type Item as object ( id
I want to create something like this. When the button clicks main form will
I want to achieve something like this inside a UIView: I have created a
I want to do something like this so I can create a modal dialog
I want to create something like a leaflet/magazine using Latex. Is it possible to
Is there a open source meme tracker ? I want to create something like
I want to try create something like Zend's Server Pagecache. What I want to
I want to make this kind of query: create procedure something @name varchar(13) as
I want to round specific corners of buttons to create something like mx.controls.ButtonBar. But
I'm want to create a menu for a status bar item like the one

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.