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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:29:23+00:00 2026-06-02T16:29:23+00:00

I have the following TabActivity Now when I select Settle Amt tab , the

  • 0

I have the following TabActivity

enter image description here

Now when I select “Settle Amt” tab , the imagebutton on the top should change to another ImageButton, and when “Members” tab is selected, no button should be displayed. ImageButton is in the TabActivity.How can I achieve button change dynamically based on selecting the tabs?

Here is my TabActivity :

public class TransactionTab extends TabActivity{
    String groupid="";
    TabHost tb;
    TabSpec tab1,tab2,tab3;
    Intent translist,settleamt,mems;
    Context context = TransactionTab.this;
    ImageButton v_createtrans;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.transactiontab);

        Intent grpintent = getIntent();
        groupid = grpintent.getStringExtra("grpid");

        tb = (TabHost)findViewById(android.R.id.tabhost);
        v_createtrans = (ImageButton)findViewById(R.id.x_createtrans);

        tab1 = tb.newTabSpec("id1");
        tab2 = tb.newTabSpec("id2");
        tab3 = tb.newTabSpec("id3");

        mems = new Intent(context,MemberList.class);
        mems.putExtra("grpid", groupid);
        mems.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        translist = new Intent(context,TransactionList.class);
        translist.putExtra("grpid", groupid);
        translist.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        settleamt = new Intent(context,SettleAmount.class);
        settleamt.putExtra("grpid", groupid);
        settleamt.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        View layview = LayoutInflater.from(context).inflate(R.layout.tab_buttonbg, null);
        Button bt = (Button) layview.findViewById(R.id.tabuton);
        bt.setText("Members");
        tab1.setIndicator(layview);
        tab1.setContent(mems);

        layview = LayoutInflater.from(context).inflate(R.layout.tab_buttonbg, null);
        Button bt1 = (Button) layview.findViewById(R.id.tabuton);
        bt1.setText("Transactions");
        tab2.setIndicator(layview);
        tab2.setContent(translist);

        layview = LayoutInflater.from(context).inflate(R.layout.tab_buttonbg, null);
        Button bt2 = (Button) layview.findViewById(R.id.tabuton);
        bt2.setText("Settle Amt");
        tab3.setIndicator(layview);
        tab3.setContent(settleamt);

        tb.getTabWidget().setDividerDrawable(R.drawable.divider);

        tb.addTab(tab1);
        tb.addTab(tab2);
        tb.addTab(tab3);

        tb.setCurrentTab(1);

        v_createtrans.setOnClickListener(new OnClickListener(){
            public void onClick(View v){
                Intent newtrans = new Intent(context,NewTransaction.class);
                newtrans.putExtra("grpid", groupid);
                startActivity(newtrans);
            }
        });

    }

and layout xml :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:background="@color/grey_color">

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@color/app_header_color">

        <ImageButton 
            android:id="@+id/x_createtrans"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/addbtn"
            android:layout_alignParentRight="true"
            android:layout_centerVertical="true"
            android:layout_marginRight="10dp"
            android:background="@null">
        </ImageButton>

    </RelativeLayout>

    <TabHost
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@android:id/tabhost">

        <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="fill_parent"
         android:orientation="vertical">

            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="#ffffff">
            </TabWidget>

            <FrameLayout
                android:layout_height="fill_parent"
                android:layout_width="fill_parent"
                android:id="@android:id/tabcontent">
            </FrameLayout>

        </LinearLayout>

    </TabHost>

</LinearLayout>
  • 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-02T16:29:26+00:00Added an answer on June 2, 2026 at 4:29 pm

    try to use

       TabHost.SetOnTabChangedListener(this){
     protected void OnTabChanged()
     {
    
     }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi guyzz I have TabActivity as following simple code public class TabhostActivity extends Activity{
I have a TabActivity with a tab, which shows a list. I'd like to
I have the following problem. I am in a tabActivity with 2 tabs. Every
i have following url structure http://www.mydomain.com/vpn-offers-p3.html this page should be redirect to http://www.mydomain.com/vpn-offers.php?st=60&page=3 here
I have a tabactivity with several tabs. Each tab has an ActivityGroup associated with
Have following String built SQL query: StringBuilder querySelect = new StringBuilder(select * from messages
I have following problem: I have a TabActivity which works well. Inside, there is
I have a TabActivity where each tab has ActivityGroup. On the home ActivityChild of
I have used Experience - Multiple Android Activities in a TabActivity to implement tab.
I have following method in wcf webenabled service Public Person AddPerson(Person p); As of

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.