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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:48:04+00:00 2026-06-16T23:48:04+00:00

I am trying to place a button in the TabWidget, meaning that I want

  • 0

I am trying to place a button in the TabWidget, meaning that I want to see all the tabs and the most right one will be a button.
I couldn’t do it with the xml (and it will be helpful if someone would tell me how) so I’ve added the button by code.
The problem is that the button is not clicked, I hear the click sound from the device but nothing happens, I don’t see that the OnClickListener is called.
Can you please look at the code and tell me what I am doing wrong?
This code is at the onCreate() of my activity.

TabWidget tabWidget = (TabWidget)findViewById(android.R.id.tabs);

Button button = new Button(this);
button.setBackgroundResource(R.drawable.settings);
button.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
button.setClickable(true);
button.setOnClickListener(new OnClickListener() {

    @Override
    public void onClick(View v) {
        LogWrapper.d(TAG, "************************************");
        startActivity(new Intent(MyActivity.this, SettingsActivity.class));
    }
});
tabWidget.addView(button);
  • 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-16T23:48:05+00:00Added an answer on June 16, 2026 at 11:48 pm

    I have a solution, I don’t know if it’s the best one, but it’s something to offer.

    I’ve built xml file with a single button in it, inflate it and add it to the TabWidget, this seems to work.

    settings_button.xml

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    
        <Button
            android:id="@+id/settingsButton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/settings" >
        </Button>
    
    </LinearLayout>
    

    MyActivity.java

    TabWidget tabWidget = (TabWidget)findViewById(android.R.id.tabs);
    
    View layout = LayoutInflater.from(this).inflate(R.layout.settings_button, null);
    Button button = (Button)layout.findViewById(R.id.settingsButton);
    button.setOnClickListener(new OnClickListener() {
    
        @Override
        public void onClick(View v) {
            LogWrapper.d(TAG, "*****************************************************");
            startActivity(new Intent(MyActivity.this, SettingsActivity.class));
        }
    });
    layout.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
    tabWidget.addView(layout);
    

    Anyway, this is my solution offer. After checking it, it doesn’t look good a button in the TabWidget. I’ll think what to do with it.

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

Sidebar

Related Questions

I am trying to place a Dismiss or Done button in the top right
I am trying to move an label/icon & button from one place to another
I`m trying to place all form fields (and the submit button) on a single
I am trying to place a back to home button on all of the
I'm trying to place a play button over an image that has a 3px
I'm trying to place a button. I have its position set to absolute, so
I am trying to put a JavaFX button in a specific place (specific coordinates)
I am trying to place a hyperlink in one of my NSIS pages. My
I am trying to place API variables on ONE class file or mxml file
I'm trying to place a nice border around an image that's 250x250, using only

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.