ogaclejapan / SmartTabLayout

A custom ViewPager title strip which gives continuous feedback to the user when scrolling

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Set Tab Icon on the basis of tab name

sebinpaul opened this issue · comments

First of all thank you for such a great library!

The normal icon tabs are implemented this way-

layout.setCustomTabView(new SmartTabLayout.TabProvider() {
@OverRide
public View createTabView(ViewGroup container, int position, PagerAdapter adapter) {
ImageView icon = (ImageView) inflater.inflate(R.layout.custom_tab_icon1, container,
false);
switch (position) {
case 0:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_home_white_24dp));
break;
case 1:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_search_white_24dp));
break;
case 2:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_person_white_24dp));
break;
case 3:
icon.setImageDrawable(res.getDrawable(R.drawable.ic_flash_on_white_24dp));
break;
default:
throw new IllegalStateException("Invalid position: " + position);
}
return icon;
}
});

In this code snippet icons are set on the basis of position. Is there any way I can set it on the basis of tab title?(instead of position, tab title could be used) Actually in my I give the users the ability to reorder/disable tabs.

Is there any way I can achieve this?