Thursday, 23 August 2012

Android: Change Tab Text Color




     
   

Android: Change Tab Text Color





 TabHost tabHost = getTabHost();
     
        TabSpec wotspec = tabHost.newTabSpec("WOT      WOT   .");
         wotspec.setIndicator("WOT      WOT    .", getResources().getDrawable(R.drawable.finalimg));
        Intent wotIntent = new Intent(this, wot.class);
        wotspec.setContent(wotIntent);

   
        TabSpec moviespec = tabHost.newTabSpec("MOVIES     MOVIES  .");
        moviespec.setIndicator("MOVIES    MOVIES   .", getResources().getDrawable(R.drawable.movies));
        Intent movieIntent = new Intent(this, movie.class);
        moviespec.setContent(movieIntent);

       
        TabSpec theatrespec = tabHost.newTabSpec("THEATRE   THEATRE  .");
        theatrespec.setIndicator("THEATRE    THEATRE .", getResources().getDrawable(R.drawable.theatre));
        Intent theatreIntent = new Intent(this, theatre.class);
        theatrespec.setContent(theatreIntent);
       
        TabSpec book = tabHost.newTabSpec("BOOK TICKET   BOOK TICKET");
        book.setIndicator("BOOK TICKET   BOOK TICKET", getResources().getDrawable(R.drawable.finalimg));
        Intent bookIntent = new Intent(this, book.class);
        book.setContent(bookIntent);
       
        TabSpec map = tabHost.newTabSpec("MAP      MAP  .");
        map.setIndicator("MAPS      MAP   .", getResources().getDrawable(R.drawable.finalimg));
        Intent mapIntent = new Intent(this, map.class);
        map.setContent(mapIntent);
       
                 
     
        tabHost.addTab(wotspec);
        tabHost.addTab(moviespec);
        tabHost.addTab(theatrespec);
        tabHost.addTab(book);
        tabHost.addTab(map);
       
       
        for(int i=0;i< tabHost.getTabWidget().getChildCount();i++)
        {
            TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
            tv.setTextColor(Color.parseColor("#160F0F"));
        }
     

2 comments:

  1. I did this as you suggest but it give me nullpointer exaception on textview of Title.

    ReplyDelete
  2. please remove your this post ,it will mislead to other developer instead of benefit,

    ReplyDelete