本文整理匯總了Java中com.actionbarsherlock.app.ActionBar.Tab類的典型用法代碼示例。如果您正苦於以下問題:Java Tab類的具體用法?Java Tab怎麽用?Java Tab使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Tab類屬於com.actionbarsherlock.app.ActionBar包,在下文中一共展示了Tab類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// TODO Auto-generated method stub
switch(tab.getPosition()) {
case 0:
NormalFragment frag = new NormalFragment();
ft.replace(android.R.id.content, frag);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#33b5e5")));
enableNormal();
break;
case 1:
BatteryFragment frag1 = new BatteryFragment();
ft.replace(android.R.id.content, frag1);
getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor("#ff5858")));
enableBattery();
break;
}
}
示例2: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction transaction) {
switch (tab.getPosition()) {
case POSITION_TAB_NUMERIC:
mWebViewTab1.setVisibility(View.VISIBLE);
mWebViewTab2.setVisibility(View.GONE);
mWebViewTab3.setVisibility(View.GONE);
break;
case POSITION_TAB_QUICKNAV:
mWebViewTab1.setVisibility(View.GONE);
mWebViewTab2.setVisibility(View.VISIBLE);
mWebViewTab3.setVisibility(View.GONE);
break;
case POSITION_TAB_ADVANCED:
mWebViewTab1.setVisibility(View.GONE);
mWebViewTab2.setVisibility(View.GONE);
mWebViewTab3.setVisibility(View.VISIBLE);
break;
default:
break;
}
}
示例3: onCreate
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
setTheme(SampleList.THEME); //Used for theme switching in samples
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_navigation);
mSelected = (TextView)findViewById(R.id.text);
getSupportActionBar().setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
for (int i = 1; i <= 3; i++) {
ActionBar.Tab tab = getSupportActionBar().newTab();
tab.setText("Tab " + i);
tab.setTabListener(this);
getSupportActionBar().addTab(tab);
}
}
示例4: addFragment
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
public void addFragment(Fragment fragment)
{
// Select proper stack
Tab tab = getSupportActionBar().getSelectedTab();
Stack<String> backStack = backStacks.get(tab.getTag());
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
// Animate transfer to new fragment
// ft.setCustomAnimations(R.anim.slide_from_left, R.anim.slide_to_right);
// Get topmost fragment
String tag = backStack.peek();
Fragment top = getSupportFragmentManager().findFragmentByTag(tag);
ft.detach(top);
// Add new fragment
addFragment(fragment, backStack, ft);
ft.commit();
}
示例5: onResume
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
protected void onResume()
{
super.onResume();
// Select proper stack
Tab tab = getSupportActionBar().getSelectedTab();
Stack<String> backStack = backStacks.get(tab.getTag());
if (! backStack.isEmpty())
{
// Restore topmost fragment (e.g. after application switch)
String tag = backStack.peek();
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
if (fragment.isDetached())
{
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.attach(fragment);
ft.commit();
}
}
}
示例6: onPause
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
protected void onPause()
{
super.onPause();
// Select proper stack
Tab tab = getSupportActionBar().getSelectedTab();
Stack<String> backStack = backStacks.get(tab.getTag());
if (! backStack.isEmpty())
{
// Detach topmost fragment otherwise it will not be correctly displayed
// after orientation change
String tag = backStack.peek();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
ft.detach(fragment);
ft.commit();
}
}
示例7: onBackPressed
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onBackPressed()
{
// Select proper stack
Tab tab = getSupportActionBar().getSelectedTab();
Stack<String> backStack = backStacks.get(tab.getTag());
String tag = backStack.pop();
if (backStack.isEmpty())
{
// Let application finish
super.onBackPressed();
}
else
{
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
// Animate return to previous fragment
// ft.setCustomAnimations(R.anim.slide_from_right, R.anim.slide_to_left);
// Remove topmost fragment from back stack and forget it
ft.remove(fragment);
showFragment(backStack, ft);
ft.commit();
}
}
示例8: onTabReselected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabReselected(Tab tab, FragmentTransaction ft)
{
// Select proper stack
Stack<String> backStack = backStacks.get(tab.getTag());
// if (backStack.size() > 1)
// ft.setCustomAnimations(R.anim.slide_from_right, R.anim.slide_to_left);
// Clean the stack leaving only initial fragment
while (backStack.size() > 1)
{
// Pop topmost fragment
String tag = backStack.pop();
Fragment fragment = getSupportFragmentManager().findFragmentByTag(tag);
// Remove it
ft.remove(fragment);
}
showFragment(backStack, ft);
}
示例9: onCreate
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.codecs_pager);
final ActionBar ab = getSupportActionBar();
ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
ab.setDisplayShowHomeEnabled(true);
ab.setDisplayShowTitleEnabled(true);
mViewPager = (ViewPager) findViewById(R.id.pager);
TabsAdapter tabAdapter = new TabsAdapter(this, ab, mViewPager);
useCodecsPerSpeed = SipConfigManager.getPreferenceBooleanValue(this, SipConfigManager.CODECS_PER_BANDWIDTH);
showVideoCodecs = SipConfigManager.getPreferenceBooleanValue(this, SipConfigManager.USE_VIDEO);
if(useCodecsPerSpeed) {
Tab audioNb = ab.newTab().setText( R.string.slow ).setIcon(R.drawable.ic_prefs_media);
Tab audioWb = ab.newTab().setText( R.string.fast ).setIcon(R.drawable.ic_prefs_media);
tabAdapter.addTab(audioWb, CodecsFragment.class);
tabAdapter.addTab(audioNb, CodecsFragment.class);
if(showVideoCodecs) {
Tab videoNb = ab.newTab().setText( R.string.slow ).setIcon(R.drawable.ic_prefs_media_video);
Tab videoWb = ab.newTab().setText( R.string.fast ).setIcon(R.drawable.ic_prefs_media_video);
tabAdapter.addTab(videoWb, CodecsFragment.class);
tabAdapter.addTab(videoNb, CodecsFragment.class);
}
}else {
Tab audioTab = ab.newTab().setIcon(R.drawable.ic_prefs_media);
tabAdapter.addTab(audioTab, CodecsFragment.class);
if(showVideoCodecs) {
Tab videoTab = ab.newTab().setIcon(R.drawable.ic_prefs_media_video);
tabAdapter.addTab(videoTab, CodecsFragment.class);
}
}
}
示例10: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
clearDetails();
if (mViewPager.getCurrentItem() != tab.getPosition()) {
mViewPager.setCurrentItem(tab.getPosition(), true);
}
}
示例11: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
// on tab selected
// show respected fragment view
viewPager.setCurrentItem(tab.getPosition());
}
示例12: addTab
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args){
TabInfo info = new TabInfo(clss, args);
tab.setTag(info);
tab.setTabListener(this);
mTabs.add(info);
mActionBar.addTab(tab);
notifyDataSetChanged();
}
示例13: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
Object tag = tab.getTag();
for (int i = 0, n = mTabs.size(); i < n; i++) {
if (mTabs.get(i) == tag) {
mSelectedItem = i;
mViewPager.setCurrentItem(i);
break;
}
}
}
示例14: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(Tab tab, FragmentTransaction ft) {
Object tag = tab.getTag();
for (int i = 0; i < mTabs.size(); i++) {
if (mTabs.get(i) == tag) {
mViewPager.setCurrentItem(i);
}
}
}
示例15: onTabSelected
import com.actionbarsherlock.app.ActionBar.Tab; //導入依賴的package包/類
@Override
public void onTabSelected(final Tab tab, final FragmentTransaction ft) {
mParent.removeAllViews();
if (mFragment == null) {
mFragment = Fragment.instantiate(mActivity, mClass.getName());
ft.add(mParent.getId(), mFragment, mTag);
} else {
// If it exists, simply attach it in order to show it
ft.attach(mFragment);
}
}