Created
February 19, 2016 15:51
-
-
Save cutiko/25d7cfcb0e35b4646c49 to your computer and use it in GitHub Desktop.
Two state icons for tabs adapter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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