Exemplo n.º 1
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ViewPager viewPager = new ViewPager(this);
    viewPager.setId(R.id.pager);
    setContentView(viewPager);

    ActionBar actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayOptions(1, ActionBar.DISPLAY_SHOW_TITLE);
    actionBar.setDisplayHomeAsUpEnabled(true);

    TabsAdapter tabsAdapter = new TabsAdapter(this, viewPager, MbwManager.getInstance(this));

    buyBitcoinTab = actionBar.newTab();
    tabsAdapter.addTab(
        buyBitcoinTab.setText(getString(R.string.gd_buy_tab)), GlideraBuyFragment.class, null);

    Tab sellBitcoinTab = actionBar.newTab();
    tabsAdapter.addTab(
        sellBitcoinTab.setText(getString(R.string.gd_sell_tab)), GlideraSellFragment.class, null);

    Tab transactionHistoryTab = actionBar.newTab();
    tabsAdapter.addTab(
        transactionHistoryTab.setText(getString(R.string.gd_transaction_history_tab)),
        GlideraTransactionHistoryFragment.class,
        null);

    Bundle bundle = getIntent().getExtras();

    if (bundle != null) {
      String tab = getIntent().getExtras().getString("tab");

      if (tab.equals("buy")) {
        actionBar.selectTab(buyBitcoinTab);
      } else if (tab.equals("sell")) {
        actionBar.selectTab(sellBitcoinTab);
      } else if (tab.equals("history")) {
        actionBar.selectTab(transactionHistoryTab);
      } else {
        actionBar.selectTab(buyBitcoinTab);
      }
    } else {
      actionBar.selectTab(buyBitcoinTab);
    }
  }
Exemplo n.º 2
0
 @Override
 public void onBackPressed() {
   ActionBar bar = getSupportActionBar();
   if (bar.getSelectedTab() == buyBitcoinTab) {
     super.onBackPressed();
   } else {
     bar.selectTab(buyBitcoinTab);
   }
 }
  @Override
  public void selectTab(TabProxy tabProxy) {
    TiUIActionBarTab tabView = (TiUIActionBarTab) tabProxy.peekView();
    if (tabView == null) {
      // The tab has probably not been added to this group yet.
      return;
    }

    tabClicked = false;
    if (activityPaused) {
      // Action bar does not allow tab selection if the activity is paused.
      // Postpone the tab selection until the activity resumes.
      selectedTabOnResume = tabView.tab;

    } else {
      actionBar.selectTab(tabView.tab);
    }
  }