@Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    //	      if(getSupportFragmentManager().findFragmentByTag("Equalizer")!=null){
    //	    	  getSupportFragmentManager().beginTransaction().remove(equalizerFragment).commit();
    //	      }

    if (tab.getPosition() == 0) {

      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container, simpleListFragment)
          .commit();
    } else if (tab.getPosition() == 1) {

      getSupportFragmentManager().beginTransaction().replace(R.id.container, androidlidt).commit();
    } else if (tab.getPosition() == 2) {

      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container, androidversionlist)
          .commit();
    } else if (tab.getPosition() == 3) {
      getSupportFragmentManager()
          .beginTransaction()
          .replace(R.id.container, azimuthControl)
          .commit();
    } else {
      getSupportFragmentManager().beginTransaction().replace(R.id.container, audioFxFrag).commit();
    }
  }
Пример #2
0
  @Override
  public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
    // When the given tab is selected, switch to the corresponding page in
    // the ViewPager.
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
      actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
    }

    assert actionBar != null;

    switch (tab.getPosition()) {
      case 0:
        actionBar.setSubtitle(getString(R.string.title_section_name1));
        break;
      case 1:
        actionBar.setSubtitle(getString(R.string.title_section_name2));
        break;
      case 2:
        actionBar.setSubtitle(getString(R.string.title_section_name3));
        break;
      case 3:
        actionBar.setSubtitle(getString(R.string.title_section_name4));
        break;
      case 4:
        actionBar.setSubtitle(getString(R.string.title_section_name5));
        break;
    }

    mViewPager.setCurrentItem(tab.getPosition());
  }
Пример #3
0
 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();
 }
 @Override
 public Fragment getItem(int i) {
   if (tabsDisabled) {
     return savedFragment;
   } else {
     ActionBar.Tab tab = actionBar.getTabAt(i);
     TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag();
     if (tabView.fragment == null) {
       tabView.initializeFragment();
     }
     return tabView.fragment;
   }
 }
  @Override
  public void addTab(TabProxy tabProxy) {
    ActionBar.Tab tab = actionBar.newTab();
    tab.setTabListener(this);

    // Create a view for this tab proxy.
    TiUIActionBarTab actionBarTab = new TiUIActionBarTab(tabProxy, tab);
    tabProxy.setView(actionBarTab);

    // Add the new tab, but don't select it just yet.
    // The selected tab is set once the group is done opening.
    actionBar.addTab(tab, false);
    tabGroupPagerAdapter.notifyDataSetChanged();
    int numTabs = actionBar.getTabCount();
    int offscreen = numTabs > 1 ? numTabs - 1 : 1; // Must be at least 1
    tabGroupViewPager.setOffscreenPageLimit(offscreen);
  }
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
   Object tag = tab.getTag();
   for (int i = 0; i < mTabs.size(); i++) {
     if (mTabs.get(i) == tag) {
       mViewPager.setCurrentItem(i);
     }
   }
 }
Пример #7
0
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
   int position = tab.getPosition();
   QBUser qbUser = ((App) getApplication()).getQbUser();
   if (qbUser != null) {
     viewPager.setCurrentItem(position);
   } else if (position == POSITION_ROOM) {
     lastAction = Action.ROOM_LIST;
     showAuthenticateDialog();
   }
 }
 public void disableTabNavigation(boolean disable) {
   if (disable && actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_TABS) {
     savedSwipeable = swipeable;
     swipeable = false;
     ActionBar.Tab tab = actionBar.getSelectedTab();
     if (tab == null) {
       Log.e(TAG, "No selected tab when trying to disable Tab Navigation");
       return;
     }
     TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag();
     savedFragment = tabView.fragment;
     tabsDisabled = true;
     tabGroupPagerAdapter.notifyDataSetChanged();
     actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
   } else if (!disable && actionBar.getNavigationMode() == ActionBar.NAVIGATION_MODE_STANDARD) {
     tabsDisabled = false;
     savedFragment = null;
     actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
     tabGroupPagerAdapter.notifyDataSetChanged();
     swipeable = savedSwipeable;
   }
 }
  @Override
  public TabProxy getSelectedTab() {
    ActionBar.Tab tab;
    try {
      tab = actionBar.getSelectedTab();
    } catch (NullPointerException e) {
      // This is a workaround for AppCompat actionbar 4.0+. There is a bug in AppCompat source that
      // will cause a null pointer exception if no tab is selected instead of returning null. See
      // source at:
      // https://android.googlesource.com/platform/frameworks/support/+/89208232f3b5d1451408d787872504a190bc7ee0/v7/appcompat/src/android/support/v7/app/ActionBarImplICS.java
      // line 259.
      tab = null;
    }
    if (tab == null) {
      // There is no selected tab currently for this action bar.
      // This probably means the tab group contains no tabs.
      return null;
    }

    TiUIActionBarTab tabView = (TiUIActionBarTab) tab.getTag();
    return (TabProxy) tabView.getProxy();
  }
Пример #10
0
  private void setActionBar(ActionBar actionBar) {

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    ActionBar.Tab tab1 = actionBar.newTab();
    tab1.setText("Home");
    tab1.setTabListener(this);

    actionBar.addTab(tab1);

    ActionBar.Tab tab2 = actionBar.newTab();
    tab2.setText("Favorite");
    tab2.setTabListener(this);
    actionBar.addTab(tab2);
  }
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
   // When the given tab is selected, switch to the corresponding page in
   // the ViewPager.
   mViewPager.setCurrentItem(tab.getPosition());
 }
Пример #12
0
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
   mViewPager.setCurrentItem(tab.getPosition());
 }
Пример #13
0
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
   // on tab selected
   // show respected fragment view
   viewPager.setCurrentItem(tab.getPosition());
 }
Пример #14
0
 @Override
 public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
   pager.setCurrentItem(tab.getPosition());
   // mSelectedFragments = (String) tab.getText();
 }
Пример #15
0
 @Override
 public void onTabSelected(ActionBar.Tab tab, android.support.v4.app.FragmentTransaction ft) {
   viewPager.setCurrentItem(tab.getPosition());
 }
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (savedInstanceState == null) {
      Date date = new Date();
      SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
      sdf.setTimeZone(TimeZone.getTimeZone("EST5EDT"));
      String now = sdf.format(date);

      prefs = getSharedPreferences(prefName, MODE_PRIVATE);
      SharedPreferences.Editor editor = prefs.edit();
      editor.putString(ACTIVE_KEY, now);
      editor.commit();
      db = new TableDbAdapter(getApplicationContext());

      try {
        if (getIntent().getExtras().getString("type").equals("usercheck")) {
          Toast.makeText(
                  getBaseContext(),
                  "Welcome back, " + prefs.getString(KEY_USERNAME, "") + "!",
                  Toast.LENGTH_SHORT)
              .show();
        }
      } catch (NullPointerException e) {
        // TODO: handle exception
        e.printStackTrace();
      }
    }

    setContentView(R.layout.main);

    actionBar = getSupportActionBar();

    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);

    if (metrics.heightPixels < 400 && metrics.widthPixels < 300) {
      actionBar.setDisplayShowTitleEnabled(false);
      actionBar.setDisplayShowHomeEnabled(false);
    } else {
      actionBar.setDisplayUseLogoEnabled(true);
    }

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    ActionBar.Tab tabCalendar = actionBar.newTab().setText("Calendar");
    ActionBar.Tab tabTotals = actionBar.newTab().setText("Totals");
    ActionBar.Tab tabDetails = actionBar.newTab().setText("User Info");

    Fragment fragmentCalendar = new FragmentCalendar();
    Fragment fragmentTotals = new FragmentTotals();
    Fragment fragmentDetails = new FragmentDetails();

    tabCalendar.setTabListener(new MyTabsListener(fragmentCalendar));
    tabTotals.setTabListener(new MyTabsListener(fragmentTotals));
    tabDetails.setTabListener(new MyTabsListener(fragmentDetails));

    actionBar.addTab(tabCalendar);
    actionBar.addTab(tabTotals);
    actionBar.addTab(tabDetails);
  }