本文整理匯總了Java中android.support.v7.app.ActionBar.Tab類的典型用法代碼示例。如果您正苦於以下問題:Java Tab類的具體用法?Java Tab怎麽用?Java Tab使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Tab類屬於android.support.v7.app.ActionBar包,在下文中一共展示了Tab類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeTabAt
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public void removeTabAt(int position) {
if (this.mTabScrollView != null) {
int selectedTabPosition = this.mSelectedTab != null ? this.mSelectedTab.getPosition() : this.mSavedTabPosition;
this.mTabScrollView.removeTabAt(position);
TabImpl removedTab = (TabImpl) this.mTabs.remove(position);
if (removedTab != null) {
removedTab.setPosition(-1);
}
int newTabCount = this.mTabs.size();
for (int i = position; i < newTabCount; i++) {
((TabImpl) this.mTabs.get(i)).setPosition(i);
}
if (selectedTabPosition == position) {
Tab tab;
if (this.mTabs.isEmpty()) {
tab = null;
} else {
TabImpl tabImpl = (TabImpl) this.mTabs.get(Math.max(0, position - 1));
}
selectTab(tab);
}
}
}
示例2: setupTabs
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
@SuppressWarnings("deprecation")
private void setupTabs(){
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
String title = getString(R.string.artist);
Tab tab = actionBar.newTab()
.setText(title)
.setTabListener(new ActionBarTabListener<PlaceHolderFragment>(
this, title, PlaceHolderFragment.class, PlaceHolderFragment.getBundle(title)));
actionBar.addTab(tab);
title = getString(R.string.album);
tab = actionBar.newTab()
.setText(R.string.album)
.setTabListener(new ActionBarTabListener<PlaceHolderFragment>(
this, "album", PlaceHolderFragment.class, PlaceHolderFragment.getBundle(title)));
actionBar.addTab(tab);
}
示例3: configureTabs
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
protected void configureTabs(final ActionBar actionBar, ViewPager viewPager) {
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
// For each of the sections in the app, add a tab to the action bar.
for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
Tab newTab = actionBar.newTab()
.setText(mSectionsPagerAdapter.getPageTitle(i))
.setTabListener(this);
actionBar.addTab(newTab);
}
}
示例4: performTabClick
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
private void performTabClick(Tab tab) {
switch (tab.getPosition()) {
case 0:
if (spnAllStations != null) {
spnAllStations.performClick();
}
break;
case 1:
AnalyticsUtil.sendEvent(AnalyticsUtil.UI_ACTION, "click_tab_favourites", "station: " + Constants.SELECTED_STATION_NAME_VALUE);
this.startActivityForResult(new Intent(this, FavouritesActivity.class), Constants.FROM_FAVOURITES);
break;
case 2:
AnalyticsUtil.sendEvent(AnalyticsUtil.UI_ACTION, "click_musicBrowser", "station: " + Constants.SELECTED_STATION_NAME_VALUE);
this.startActivity(new Intent(this, FileChooserActivity.class));
// Fragments
// FragmentManager fm = getSupportFragmentManager();
// FileChooserFragment fileList = new FileChooserFragment();
// fm.beginTransaction().replace(android.R.id.content, fileList).commit();
break;
default:
break;
}
}
示例5: setActionBar
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
private void setActionBar() {
actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
// actionBar.setTitle(getResources().getString(R.string.str_title_contacts_manager));
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
Tab contactsTab = actionBar.newTab();
contactsTab.setText(getString(R.string.str_contacts));
contactsTab.setTabListener(contactsTabListener);
actionBar.addTab(contactsTab);
Tab groupsTab = actionBar.newTab();
groupsTab.setText(getString(R.string.str_lists));
groupsTab.setTabListener(groupsTabListener);
actionBar.addTab(groupsTab);
}
示例6: configureTabNavigation
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
/**
* Configures the {@link ActionBar} to display navigation tabNames.
*
* @param actionBar the {@link ActionBar} to customize.
* @param names the collection of tab names.
* @param listener the {@link TabListener} to handle tab selection events.
*/
public static void configureTabNavigation(final ActionBar actionBar, final List<String> names,
final TabListener listener) {
if (listener == null) {
throw new IllegalArgumentException("TabListener must be supplied");
}
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (final String name : names) {
final Tab tab = actionBar.newTab();
tab.setTabListener(listener);
tab.setText(name);
actionBar.addTab(tab);
}
}
示例7: onTabSelected
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction arg1) {
viewPager.setCurrentItem(tab.getPosition());
// if (tab.getPosition() == TabPagerAdapter.FRIENDS_TAB) {
// txtBottomHint.setText(R.string.select_a_friend);
// } else {
// String text = (userSearched.length() != 0) ? String.format(
// getString(R.string.username_history), userSearched)
// : getString(R.string.search_for_a_mal_friend);
// txtBottomHint.setText(text);
// }
String text = (userSearched.length() != 0) ? String.format(
getString(R.string.username_history), userSearched)
: getString(R.string.search_for_a_mal_friend);
txtBottomHint.setText(text);
}
示例8: setCustomView
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public Tab setCustomView(View view) {
this.mCustomView = view;
if (this.mPosition >= 0) {
WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
}
return this;
}
示例9: setIcon
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public Tab setIcon(Drawable icon) {
this.mIcon = icon;
if (this.mPosition >= 0) {
WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
}
return this;
}
示例10: setText
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public Tab setText(CharSequence text) {
this.mText = text;
if (this.mPosition >= 0) {
WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
}
return this;
}
示例11: setContentDescription
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public Tab setContentDescription(CharSequence contentDesc) {
this.mContentDesc = contentDesc;
if (this.mPosition >= 0) {
WindowDecorActionBar.this.mTabScrollView.updateTab(this.mPosition);
}
return this;
}
示例12: setSelectedNavigationItem
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public void setSelectedNavigationItem(int position) {
switch (this.mDecorToolbar.getNavigationMode()) {
case 1:
this.mDecorToolbar.setDropdownSelectedPosition(position);
return;
case 2:
selectTab((Tab) this.mTabs.get(position));
return;
default:
throw new IllegalStateException("setSelectedNavigationIndex not valid for current navigation mode");
}
}
示例13: configureTab
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
private void configureTab(Tab tab, int position) {
TabImpl tabi = (TabImpl) tab;
if (tabi.getCallback() == null) {
throw new IllegalStateException("Action Bar Tab must have a Callback");
}
tabi.setPosition(position);
this.mTabs.add(position, tabi);
int count = this.mTabs.size();
for (int i = position + 1; i < count; i++) {
((TabImpl) this.mTabs.get(i)).setPosition(i);
}
}
示例14: addTab
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public void addTab(Tab tab, boolean setSelected) {
ensureTabsExist();
this.mTabScrollView.addTab(tab, setSelected);
configureTab(tab, this.mTabs.size());
if (setSelected) {
selectTab(tab);
}
}
示例15: selectTab
import android.support.v7.app.ActionBar.Tab; //導入依賴的package包/類
public void selectTab(Tab tab) {
int i = -1;
if (getNavigationMode() != 2) {
this.mSavedTabPosition = tab != null ? tab.getPosition() : -1;
return;
}
FragmentTransaction trans;
if (!(this.mActivity instanceof FragmentActivity) || this.mDecorToolbar.getViewGroup().isInEditMode()) {
trans = null;
} else {
trans = ((FragmentActivity) this.mActivity).getSupportFragmentManager().beginTransaction().disallowAddToBackStack();
}
if (this.mSelectedTab != tab) {
ScrollingTabContainerView scrollingTabContainerView = this.mTabScrollView;
if (tab != null) {
i = tab.getPosition();
}
scrollingTabContainerView.setTabSelected(i);
if (this.mSelectedTab != null) {
this.mSelectedTab.getCallback().onTabUnselected(this.mSelectedTab, trans);
}
this.mSelectedTab = (TabImpl) tab;
if (this.mSelectedTab != null) {
this.mSelectedTab.getCallback().onTabSelected(this.mSelectedTab, trans);
}
} else if (this.mSelectedTab != null) {
this.mSelectedTab.getCallback().onTabReselected(this.mSelectedTab, trans);
this.mTabScrollView.animateToTab(tab.getPosition());
}
if (trans != null && !trans.isEmpty()) {
trans.commit();
}
}