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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:14:13+00:00 2026-06-13T14:14:13+00:00

In general, everything is working on Google Chrome. When the new tab button is

  • 0

In general, everything is working on Google Chrome. When the new tab button is clicked, a new tab is generated. In the same way, I want to add a new tab in the Android browser. How to do this — does anyone have any idea?

  1. First, is it possible in Android?

  2. If possible, how to do this?

    enter image description here

When I click on the + button, a new tab should be generated. How to do this?

  • 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-13T14:14:14+00:00Added an answer on June 13, 2026 at 2:14 pm

    Ok Here is the code but it’s an example only you may need to modify the code as per your requirement. I am giving you all the files code here hope you getting answer.

    Your Manifest.xml file

    <manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.android.dynamictab"
        android:versionCode="1"
        android:versionName="1.0" >
    
        <uses-sdk
            android:minSdkVersion="8"
            android:targetSdkVersion="15" />
    
        <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
            <activity
                android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
    
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
            <activity
                android:name=".BlankActivity"/>
        </application>
    
    </manifest>
    

    here is your activity_main.xml file for Tab activity

    <?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:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical"
            android:padding="5dp" >
    
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal"
                >
                <HorizontalScrollView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:fillViewport="true"
                    android:scrollbars="none" 
                    android:layout_weight="1">
    
                    <TabWidget
                        android:id="@android:id/tabs"
                        android:layout_width="fill_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginLeft="0dip"
                        android:layout_marginRight="0dip" />
                </HorizontalScrollView>
                <Button android:id="@+id/add_tab"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.1"
                    android:text="Add"/>
            </LinearLayout>
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:padding="2dp" />
        </LinearLayout>
    
    </TabHost>
    

    Put your TabWidget into the HorizontalScrollView so when more tabs are add it can scrolling and the Add but is out side of HorizontalScrollView. Every time you click on tab it will add new tab in TabWidget.

    Here the code for tab_event.xml This layout will inflate and add into tab. You can change the style and its contain a single Button so you can add drawable image with text also.

    <?xml version="1.0" encoding="utf-8"?>
    <Button xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/button_event"
        android:clickable="true"
        android:focusable="true"
        android:text="Default Tab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    

    Here is your MainActivity.java file

    import android.app.TabActivity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.view.LayoutInflater;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.Button;
    import android.widget.TabHost;
    import android.widget.TabHost.TabSpec;
    
    public class MainActivity extends TabActivity {
        private static int tabIndex = 0;
        private TabHost tabHost;
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tabHost = getTabHost();
    
            addTab();
    
            ((Button)findViewById(R.id.add_tab)).setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                    tabIndex++;
                    addTab();
                }
            });
        }
        private void addTab(){
            LayoutInflater layoutInflate = LayoutInflater.from(MainActivity.this);
    
            Button tabBtn = (Button)layoutInflate.inflate(R.layout.tab_event, null);
            tabBtn.setText("Tab "+tabIndex);
            Intent tabIntent = new Intent(MainActivity.this, BlankActivity.class);
    
            setupTab(tabBtn, tabIntent,"Tab "+tabIndex);
        }
        protected void setupTab(View tabBtn, Intent setClass,String tag) {
            TabSpec setContent = tabHost.newTabSpec(tag).setIndicator(tabBtn).setContent(setClass);
            tabHost.addTab(setContent);
        }
    }
    

    And here is the BlankActivity.java file

    import android.app.Activity;
    import android.os.Bundle;
    import android.widget.TextView;
    
    public class BlankActivity extends Activity{
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            TextView tv = new TextView(BlankActivity.this);
            tv.setText("Blank activity");
            setContentView(tv);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

General question about java servlets and the best way to handle requests. If I
I've been working on a project in Eclipse and everything's been going smooth except
Background. I'm working with netlists , and in general, people specify different hierarchies by
I'm working on a general code library for ActionScript 3.0 called as3lib which includes
(The following question is for mobile platforms in general (iPhone, Android, Blackberry)) We are
I've been struggling with this for a few hours. Everything just stopped working and
I am very new to Tortoise and SVN's in general. I currently have a
I'm very new to storyboarding (also pretty new to iOS programming in general). I'm
I am new to git and to Xcode, and mac in general, so here's
I just rewrote a working program into functions in a class and everything messed

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.