Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I also have Same problem before some days. But now got solution with changing it to images. By Default First Tab is selected and when the Tab Getting change the all tab get changed automatically based on the Tab Selection.</p> <p>See below Code:</p> <pre><code> public class MainTabActivity extends TabActivity { TabHost mTabHost; TabWidget mTabWidget; private TextView title; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_tab_layout); //Resources res = getResources(); mTabHost = getTabHost(); TabHost.TabSpec spec; mTabWidget = mTabHost.getTabWidget(); Intent intent; intent = new Intent().setClass(MainTabActivity.this, TodaysDealsGroupActivity.class); spec = mTabHost.newTabSpec(getResources().getString(R.string.tab_todays_deal)).setIndicator(getResources().getString(R.string.tab_todays_deal), getResources().getDrawable(R.drawable.tab_loyalshop_selector)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(MainTabActivity.this, BuddiesGroupActivity.class); spec = mTabHost.newTabSpec(getResources().getString(R.string.tab_buddies)).setIndicator(getResources().getString(R.string.tab_buddies), getResources().getDrawable(R.drawable.tab_buddies_selector)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(MainTabActivity.this, SearchGroupActivity.class); spec = mTabHost.newTabSpec(getResources().getString(R.string.tab_search)).setIndicator(getResources().getString(R.string.tab_search), getResources().getDrawable(R.drawable.tab_search_selector)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(MainTabActivity.this, ProfileGroupActivity.class); spec = mTabHost.newTabSpec(getResources().getString(R.string.tab_profile)).setIndicator(getResources().getString(R.string.tab_profile), getResources().getDrawable(R.drawable.tab_profile_selector)).setContent(intent); mTabHost.addTab(spec); intent = new Intent().setClass(MainTabActivity.this, NotificationsGroupActivity.class); spec = mTabHost.newTabSpec(getResources().getString(R.string.tab_notifications)).setIndicator(getResources().getString(R.string.tab_notifications), getResources().getDrawable(R.drawable.tab_notification_selector)).setContent(intent); mTabHost.addTab(spec); for (int i = 0; i &lt; mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().getChildAt(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_black_bg)); title = (TextView) mTabWidget.getChildAt(i).findViewById(android.R.id.title); title.setTextColor(Color.WHITE); title.setTextSize(10); } // check if App starts from the Notification click or not if(getIntent().hasExtra("notification")){ // for the current tab selection mTabHost.getTabWidget().getChildAt(4).setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_blue_bg)); mTabHost.setCurrentTab(4); title = (TextView) mTabWidget.getChildAt(4).findViewById(android.R.id.title); }else{ // for the current tab selection mTabHost.getTabWidget().getChildAt(0).setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_blue_bg)); mTabHost.setCurrentTab(0); title = (TextView) mTabWidget.getChildAt(0).findViewById(android.R.id.title); } title.setTextColor(Color.BLACK); title.setTextSize(10); // listener for the tab changed mTabHost.setOnTabChangedListener(new OnTabChangeListener() { @Override public void onTabChanged(String tabId) { for (int i = 0; i &lt; mTabHost.getTabWidget().getChildCount(); i++) { mTabHost.getTabWidget().getChildAt(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_black_bg)); title = (TextView) mTabWidget.getChildAt(i).findViewById(android.R.id.title); title.setTextColor(Color.WHITE); title.setTextSize(10); } int tab = mTabHost.getCurrentTab(); mTabHost.getTabWidget().getChildAt(tab).setBackgroundDrawable(getResources().getDrawable(R.drawable.tab_blue_bg)); title = (TextView) mTabWidget.getChildAt(tab).findViewById(android.R.id.title); title.setTextColor(Color.BLACK); title.setTextSize(10); } }); } } </code></pre> <p>And here is the XMl file <strong>main_tab_layout.xml</strong></p> <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;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" android:layout_weight="1" &gt; &lt;LinearLayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center" android:orientation="vertical" &gt; &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /&gt; &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="bottom|center_horizontal" android:tabStripEnabled="false" &gt; &lt;/TabWidget&gt; &lt;/LinearLayout&gt; &lt;/TabHost&gt; &lt;/LinearLayout&gt; </code></pre> <p>Just Replace with your images and See the Result.</p> <p>Hope this will help you a lot as it help me.</p> <p>Enjoy Coding...</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload