Skip to main content

How to change textcolor of tab text in Android


How to change textcolor of tab text in Android

TabHost tabs = (TabHost)findViewById(R.id.TabHost01);
        tabs.setup(getLocalActivityManager());
      
      
        TabHost.TabSpec search = tabs.newTabSpec("tag1");
        search.setContent(new Intent(this,Searchgurbani.class));
        search.setIndicator("Find Me");
        tabs.addTab(search);
      
        TabHost.TabSpec pref = tabs.newTabSpec("tag5");
        pref.setContent(new Intent(this,Preferencegurbani.class));
        pref.setIndicator("Settings");
        tabs.addTab(pref);
      
        TabHost.TabSpec favorite = tabs.newTabSpec("tag6");
        favorite.setContent(new Intent(this,Favroite.class));
        favorite.setIndicator("BookMark");
        tabs.addTab(favorite);
      
        for(int i=0;i<tabs.getTabWidget().getChildCount();i++)
        {
            TextView tv = (TextView) tabs.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(Color.parseColor("#ffffff"));
        }

Comments

Post a Comment

Popular posts from this blog

Android ListView with Searchbox Sort items

This article is next step of List Example. Here we have a search box which sorts the list view as when the content matches the list items. Why do we need this? Imagine that if we have 2K to 3K items in the listview, It will not be possible to  scrolldown till 2000 th  item.In this case this will be handy to cut short items. To start with we add a edittext box and Listview added to LinearLayout. [sourcecode language="xml"] <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/LinearLayout01" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical"> <EditText android:id="@+id/EditText01" android:layout_height="wrap_content" android:layout_width="fill_parent" android:hint="Search"></EditText><ListView androi...

Class cast exception

This Exception mainly occur because when we create an action on click of a button or an action to be performed on start of an activity ,but we forget the write the code in the activity for which we wrote intent to go. for example in  a main.xml file we have 7 buttons. <ScrollView  xmlns:android="http://schemas.android.com/apk/res/android"     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="30dp" >         <TextView             android:id="@+id/textView1"             android:layout_width="wrap_content"       ...