Skip to content

Instantly share code, notes, and snippets.

@cutiko
Created February 19, 2016 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cutiko/25d7cfcb0e35b4646c49 to your computer and use it in GitHub Desktop.
Save cutiko/25d7cfcb0e35b4646c49 to your computer and use it in GitHub Desktop.
Two state icons for tabs adapter
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true"
android:state_pressed="false"
android:drawable="@drawable/selected" />
<item android:drawable="@drawable/deselected" />
</selector>
public class TabsAdapter extends FragmentStatePagerAdapter {
//Add this method to all the other override methods
public int getPageIcon(int position) {
Integer id;
switch (position){
case 0:
id = R.layout.layout_example;
break;
default:
id = R.drawable.default;
}
return id;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment