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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:59:40+00:00 2026-05-22T18:59:40+00:00

For my android application I need to implement a tabView within a LinearLayout. I

  • 0

For my android application I need to implement a tabView within a LinearLayout. I could able to add textview and button to the LinearLayout like this,

public CreateView(Context context) {
    super(context);
    LinearLayout.LayoutParams llp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    Button button = new Button(context);
    button.setText("Submit");
    button.setLayoutParams(llp);
    TextView tv = new TextView(context);
    tv.setText("This is a test");
    tv.setLayoutParams(llp);
    ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    this.addView(tv);
    this.addView(button);}

In my Activity class I added these as,

public class MyLinearLayout extends Activity {
LinearLayout ll;
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ll = new LinearLayout(this);

    ll.addView(new CreateView(this));
    setContentView(ll);

}

}

I want to do the same thing for a tabview. But I couldn’t able to find a way to add tabHost to my lineaLayout. any way to do this??
thanx

  • 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-22T18:59:41+00:00Added an answer on May 22, 2026 at 6:59 pm

    When defining the TabHost in xml and adding tabs programmatically with tabHost.newTabSpec like it’s shown in tutorial, the following structure is created:

    LinearLayout
         TabHost>
              LinearLayout
                   TabWidget
                   FrameLayout
                       LinearLayout for tab 1
                       LinearLayout for tab 2
                       ...
    

    I guess you need to replicate this nesting in code.
    The root-LinearLayout in the xml-version has width and height set to fill_parent and orientation to vertical. Maybe that’s also required for it to work.

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

Sidebar

Related Questions

I need to add a shake feature that will refresh my Android application. All
I need to implement a news feed in my android application. It should animate
I need to implement some functions into an Android application using NDK and thus
In one of my Android Application I need to keep the title bar same
I'm writing an Android application that I want to be able to send requests
My open-source Android application uses this in an SQL query: String.format(%f, someDoubleValue); Unfortunately, in
Is there any sample? I have my android application and I need to connect
Is it possible implement an Android application as a web service ? On the
In my android application i need to insert an array into an array and
I'm relatively new to java and android, in my android application I need to

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.