3

I created a tab application using Sherlock ActionBar Tab Views. I like to change the Tab title to lowercase. see screen shot

enter image description here

I want to change TAB1 to tab1

Any solution is greatly appreciated

my code as follow

public class MainActivity extends SherlockFragmentActivity {

// Declare Variables
ActionBar mActionBar;
ViewPager mPager;
Tab tab;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Get the view from activity_main.xml
    setContentView(R.layout.activity_main);

    // Activate Navigation Mode Tabs
    mActionBar = getSupportActionBar();
    mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Locate ViewPager in activity_main.xml
    mPager = (ViewPager) findViewById(R.id.pager);

    // Activate Fragment Manager
    FragmentManager fm = getSupportFragmentManager();

    // Capture ViewPager page swipes
    ViewPager.SimpleOnPageChangeListener ViewPagerListener = new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            super.onPageSelected(position);
            // Find the ViewPager Position
            mActionBar.setSelectedNavigationItem(position);
        }
    };

    mPager.setOnPageChangeListener(ViewPagerListener);
    // Locate the adapter class called ViewPagerAdapter.java
    ViewPagerAdapter viewpageradapter = new ViewPagerAdapter(fm);
    // Set the View Pager Adapter into ViewPager
    mPager.setAdapter(viewpageradapter);

    // Capture tab button clicks
    ActionBar.TabListener tabListener = new ActionBar.TabListener() {

        @Override
        public void onTabSelected(Tab tab, FragmentTransaction ft) {
            // Pass the position on tab click to ViewPager
            mPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabUnselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub
        }

        @Override
        public void onTabReselected(Tab tab, FragmentTransaction ft) {
            // TODO Auto-generated method stub
        }
    };

    // Create first Tab
    tab = mActionBar.newTab().setText("Tab1").setTabListener(tabListener);
    mActionBar.addTab(tab);

    // Create second Tab
    tab = mActionBar.newTab().setText("Tab2").setTabListener(tabListener);
    mActionBar.addTab(tab);

    // Create third Tab
    tab = mActionBar.newTab().setText("Tab3").setTabListener(tabListener);
    mActionBar.addTab(tab);

 }

thanks

Riskhan
  • 4,434
  • 12
  • 50
  • 76
  • http://stackoverflow.com/questions/9953240/tab-widget-have-always-in-capital-alphabets-in-android-4-0 See this link. – Naddy Mar 12 '14 at 09:32

3 Answers3

1

Please add this in TabLayout tag of xml file

app:tabTextAppearance="@android:style/TextAppearance.Widget.TabWidget"

this will help you :)

Vinay Rathod
  • 91
  • 1
  • 2
0

try this cod

text-transform: capitalize;
Piyush Marvaniya
  • 2,496
  • 2
  • 16
  • 28
0

Try This :-

   tab = mActionBar.newTab().setText("Tab1").setTabListener(tabListener);
    mActionBar.addTab(tab);

    TextView x1 = (TextView) mTabHost.getTabWidget().getChildAt(0)
              .findViewById(android.R.id.title);
      x1.setAllCaps(false); 

      // Create second Tab
    tab = mActionBar.newTab().setText("Tab2").setTabListener(tabListener);
    mActionBar.addTab(tab);
       TextView x2 = (TextView) mTabHost.getTabWidget().getChildAt(0)
              .findViewById(android.R.id.title);
      x2.setAllCaps(false); 
    // Create third Tab
    tab = mActionBar.newTab().setText("Tab3").setTabListener(tabListener);
    mActionBar.addTab(tab);
 TextView x3 = (TextView) mTabHost.getTabWidget().getChildAt(0)
              .findViewById(android.R.id.title);
      x3.setAllCaps(false);
Namrata
  • 1,683
  • 1
  • 17
  • 28