-
-
Save nellochen/1257063 to your computer and use it in GitHub Desktop.
Crazy tab example
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
mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); | |
mFavoritesTab = buildFavoritesTab(mActionBar.newTab()); | |
private ActionBar.Tab buildFavoritesTab(ActionBar.Tab tab) { | |
tab.setTabListener(mFavoritesTabListener); | |
TextView view = (TextView) getLayoutInflater().inflate(R.layout.tab_item, null); | |
view.setText(R.string.favorites); | |
view.setBackgroundResource(R.drawable.sub_menu_btn_left); | |
view.setTag(tab); | |
view.setOnClickListener(mOnTabClickListener); | |
return tab.setCustomView(view); | |
} | |
private ActionBar.TabListener mFavoritesTabListener = new CustomTabListener() { | |
@Override | |
public void onTabSelected(Tab tab) { | |
((TextView)tab.getCustomView()).setSelected(true); | |
// User clicked the tab | |
} | |
}; |
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
private abstract class CustomTabListener implements ActionBar.TabListener { | |
@Override | |
public void onTabUnselected(Tab tab) { | |
((TextView)tab.getCustomView()).setSelected(false); | |
} | |
@Override | |
public void onTabReselected(Tab tab) { | |
// Needed by the interface. | |
} | |
}; |
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
<TextView xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="fill_parent" | |
android:layout_height="45dip" | |
android:gravity="center_vertical|center_horizontal" | |
android:textStyle="bold" | |
android:textColor="@color/sub_menu" | |
android:focusable="true" | |
/> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment