0

I have used this library and its title text shows in upper case I have referred

but not getting the correct output.

 <style name="AppTheme" parent="@style/Theme.AppCompat.Light">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/primary</item>
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <item name="colorAccent">@color/accent</item>
    <item name="android:textColorPrimary">@color/text_color</item>
    <item name="drawerArrowStyle">@style/DrawerArrowStyle</item>
    <item name="android:actionBarTabTextStyle">@style/tab</item>
    <item name="actionBarTabTextStyle">@style/tab</item>

    <item name="android:windowBackground">@color/window_background</item>
    <item name="colorControlNormal">@color/accent</item>
    <item name="colorControlActivated">@color/secondary_text</item>
    <item name="colorControlHighlight">@color/secondary_text</item>
    <item name="android:homeAsUpIndicator">@drawable/ic_menu</item>

</style>

and

<style name="tab" parent="@style/Widget.AppCompat.Light.ActionBar.TabText">
    <item name="android:textAllCaps">false</item>
</style>

fragment.java:

    tabHost = (MaterialTabHost) v.findViewById(R.id.tabHost);
    adapter = new TabsPagerAdapter(getChildFragmentManager(), entity);
    pager = (ViewPager) v.findViewById(R.id.pager_entitiy_detail);
    pager.setOffscreenPageLimit(adapter.getCount());
    pager.setAdapter(adapter);
    adapter.notifyDataSetChanged();
    pager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            tabHost.setSelectedNavigationItem(position);
            Log.e("DashDetail", "");
        }
    });

    // insert all tabs from pagerAdapter data
    for (int i = 0; i < adapter.getCount(); i++) {
        tabHost.addTab(
                tabHost.newTab()
                        .setText(adapter.getPageTitle(i))
                        .setTabListener(this)
        );

    }

used above code for tab host and in adapter setting text but not getting lower case text.

Edric
  • 24,639
  • 13
  • 81
  • 91
Anant Shah
  • 3,744
  • 1
  • 35
  • 48

2 Answers2

1

Try this in your for loop of adding tabs

try this

TextView tv =  (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); 
tv.setAllCaps(false);

like this:--

    for (int i = 0; i < adapter.getCount(); i++) {
                tabHost.addTab(
                                 tabHost.newTab()
                                .setText(adapter.getPageTitle(i))
                                .setTabListener(this)
TextView tv =  (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); 
tv.setAllCaps(false);
                );

or You can do it like below in your PagerAdapter

@Override
        public CharSequence getPageTitle(int position) {
            Locale l = Locale.getDefault();
            switch (position) {
                case 0:
                    return "ONE".toLowerCase();
}
return null;
}

I hope it may help.

Shishram
  • 1,514
  • 11
  • 20
  • Thank you, for suggest solution. But I am getting error near "getTabWidget()" Error:cannot resolved method. @Shishram – Anant Shah Oct 14 '15 at 08:24
  • If you still looking for an answer, check edited answer.@AnantShah – Shishram Oct 23 '15 at 13:41
  • thank you ,i have done what u just done above but still not worked so i have made changes in library by go through it code and analyse it. and i found that there is mentioned .toUpperCase() and i remove from there and it works. @shishram – Anant Shah Oct 23 '15 at 13:46
1

thank you ,i have done what suggest in answer as shown above but still not worked so i have made changes in library by go through it code and analyse it. and i found that there is mentioned .toUpperCase() and i remove from there and it works.

Anant Shah
  • 3,744
  • 1
  • 35
  • 48
  • On which file you remove `.toUpperCase()`. I couldn't find it anywhere, please help me to change it. – Shihas Dec 05 '17 at 13:23