List of usage examples for android.app ActionBar setSelectedNavigationItem
@Deprecated public abstract void setSelectedNavigationItem(int position);
From source file:com.example.cherry_zhang.androidbeaconexample.LoginAndRegistration.LoginAndRegistrationActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); profile = LayoutInflater.from(this).inflate(R.layout.fragment_profile, null); login = LayoutInflater.from(this).inflate(R.layout.fragment_section_login_and_registration, null); setContentView(R.layout.activity_swipe_view_login_and_registration); //parse initialization Parse.initialize(this, "TsVbzF7jXzY1C0o86V2xxAxgSxvy4jmbyykOabPl", "VzamwWm4WswbDFxrxos2oSerQ2Av4RM6J5mNnNgr"); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.hide();//from w ww. j av a2 s. c o m // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOffscreenPageLimit(4); ViewPager.SimpleOnPageChangeListener mPageChangeListener = new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }; //mViewPager.setOnPageChangeListener( pageIndicator = (CirclePageIndicator) findViewById(R.id.CPI_pageIndicator); pageIndicator.setViewPager(mViewPager); pageIndicator.setOnPageChangeListener(mPageChangeListener); pageIndicator.setCurrentItem(0); //TODO: make circle page indicator look better final float density = getResources().getDisplayMetrics().density; pageIndicator.setRadius(5 * density); pageIndicator.setPageColor(0xFF686868); pageIndicator.setFillColor(0xFFFFFFFF); pageIndicator.setStrokeColor(0xFF000000); pageIndicator.setStrokeWidth(1); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.example.jenil.parsedemo.GameShowActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().requestFeature(Window.FEATURE_ACTION_BAR); setContentView(R.layout.activity_game_show_adapter); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./* ww w .j a v a 2 s .c om*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pagerShow); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.cachirulop.moneybox.activity.MainActivity.java
/** * Create the tabs with the sections of the application */// w ww .j a v a 2s.c o m private void createTabs() { final ActionBar actionBar = getActionBar(); // Create the adapter that will return a fragment for each of the // primary sections of the application. _sectionsPagerAdapter = new MoneyboxFragmentAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. _viewPager = (ViewPager) findViewById(R.id.pager); _viewPager.setAdapter(_sectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. _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 < _sectionsPagerAdapter.getCount(); i++) { actionBar .addTab(actionBar.newTab().setText(_sectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:ca.mymenuapp.ui.activities.MainActivity.java
/** Setup the tabs to display our fragments. */ private void setupTabs(int tab) { DelegateOnPageChangeListener delegateOnPageChangeListener = new DelegateOnPageChangeListener(); viewPager.setOnPageChangeListener(delegateOnPageChangeListener); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); SwipeableActionBarTabsAdapter tabsAdapter = new SwipeableActionBarTabsAdapter(this, viewPager, delegateOnPageChangeListener); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.map)), RestaurantsMapFragment.class, null); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.specials)), SpecialsGridFragment.class, null);// w w w .ja va2s. c o m if (!userPreference.get().isGuest()) { tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.dietary_preferences)), DietaryPreferencesFragment.class, null); tabsAdapter.addTab(actionBar.newTab().setText(getString(R.string.settings)), SettingsFragment.class, null); } actionBar.setSelectedNavigationItem(tab); delegateOnPageChangeListener.addOnPageChangeListener(new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { if (position == 0) { // Enable user to slide the drawer layout drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED); drawerToggle.setDrawerIndicatorEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); } else { // Disable user from sliding the drawer layout drawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED); drawerToggle.setDrawerIndicatorEnabled(false); getActionBar().setDisplayHomeAsUpEnabled(false); getActionBar().setHomeButtonEnabled(false); } } @Override public void onPageSelected(int position) { // ignore } @Override public void onPageScrollStateChanged(int state) { // ignore } }); }
From source file:com.example.swipedemo.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is // no hierarchical // parent./*from www.j av a 2 s . c o m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener // for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select // the corresponding tab. // We can also use ActionBar.Tab#select() to do this if // we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by // the adapter. // Also specify this Activity object, which implements the // TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.hardcopy.blechat.MainActivity.java
/***************************************************** * Overrided methods//from w w w .ja va 2s .com ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this; //.getApplicationContext(); mActivityHandler = new ActivityHandler(); AppSettings.initializeAppSettings(mContext); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the primary sections of the app. mFragmentManager = getSupportFragmentManager(); mSectionsPagerAdapter = new FragmentAdapter(mFragmentManager, mContext, this, mActivityHandler); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding tab. mViewPager.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++) { // Create a tab with text corresponding to the page title defined by the adapter. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } // Setup views mImageBT = (ImageView) findViewById(R.id.status_title); mImageBT.setImageDrawable(getResources().getDrawable(android.R.drawable.presence_invisible)); mTextStatus = (TextView) findViewById(R.id.status_text); mTextStatus.setText(getResources().getString(R.string.bt_state_init)); // Do data initialization after service started and binded doStartService(); }
From source file:com.cashout.paperless.fintech_paperless_cashout.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent.//from w w w. j a v a 2 s. c o m actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity_layout); // Create the adapter that will return a fragment for each of the three primary sections of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical parent. actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override// w w w.ja v a2 s .c o m public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the Tab. actionBar.setSelectedNavigationItem(position); } }); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the listener for when this tab is selected. actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE); ; SharedPreferences.Editor editor = settings.edit(); // load the default parameters into SharedPreferences for the first time launch int ct = settings.getInt("count", 0); if (ct == 0) { editor.putString("start", "9"); editor.putString("end", "21"); editor.putString("interval", "15"); editor.putString("duration", "5"); editor.putString("location", "On"); editor.putString("upload", "On"); TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); editor.putString("IMEI", tm.getDeviceId()); editor.putString("brand", Build.BRAND); editor.putString("model", Build.MODEL); String phone_type = Build.BRAND + "_" + Build.MODEL; // motoX if (phone_type.equals("motorola_XT1058")) { editor.putString("mfcc_dist_same_semi", "13"); editor.putString("mfcc_dist_diff_semi", "18"); editor.putString("mfcc_dist_same_un", "13"); editor.putString("mfcc_dist_diff_un", "18"); } // nexus 4 else if (phone_type.equals("google_Nexus 4")) { editor.putString("mfcc_dist_same_semi", "17"); editor.putString("mfcc_dist_diff_semi", "22"); editor.putString("mfcc_dist_same_un", "17"); editor.putString("mfcc_dist_diff_un", "22"); } // s2 else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) { editor.putString("mfcc_dist_same_semi", "18"); editor.putString("mfcc_dist_diff_semi", "25"); editor.putString("mfcc_dist_same_un", "18"); editor.putString("mfcc_dist_diff_un", "25"); } // s3 else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) { editor.putString("mfcc_dist_same_semi", "16"); editor.putString("mfcc_dist_diff_semi", "21"); editor.putString("mfcc_dist_same_un", "16"); editor.putString("mfcc_dist_diff_un", "21"); } // s4 else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) { editor.putString("mfcc_dist_same_semi", "14"); editor.putString("mfcc_dist_diff_semi", "24"); editor.putString("mfcc_dist_same_un", "14"); editor.putString("mfcc_dist_diff_un", "24"); } // other devices else { editor.putString("mfcc_dist_same_semi", "15.6"); editor.putString("mfcc_dist_diff_semi", "21.6"); editor.putString("mfcc_dist_same_un", "15.6"); editor.putString("mfcc_dist_diff_un", "21.6"); Toast.makeText(this, "Your device is not recognized and the result might not be accurate...", Toast.LENGTH_SHORT).show(); } Log.i("Crowd++", "First time launched"); AlertDialog dialog = new AlertDialog.Builder(this).create(); dialog.setTitle("Welcome to Crowd++"); dialog.setMessage(Constants.hello_msg); dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { } }); dialog.show(); dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20); } editor.putInt("count", ++ct); editor.commit(); Log.i("Launched Count", Integer.toString(ct)); mConst = new Constants(this); if (!Constants.calibration()) Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show(); }
From source file:com.hmdone.serialbluetooth.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter that will return a fragment for each of the three // primary sections of the app. mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mSectionsPagerAdapter); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*ww w .j av a 2 s. co m*/ 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++) { // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.vurf.vurfx.view.Place_template.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_place_template); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. final ActionBar actionBar = getActionBar(); final String TitleNames[] = new String[] { "About", "Main", "Photos" }; // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./* ww w . j a va2 s.co m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Set up the ViewPager, attaching the adapter and setting up a listener for when the // user swipes between sections. mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // When swiping between different app sections, select the corresponding tab. // We can also use ActionBar.Tab#select() to do this if we have a reference to the // Tab. actionBar.setSelectedNavigationItem(position); } }); // TODO swipy tabs //PagerTitleStrip mPagerTitleStrip = (PagerTitleStrip) findViewById(R.id.pager_title_strip); // For each of the sections in the app, add a tab to the action bar. for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { // Create a tab with text corresponding to the page title defined by the adapter. // Also specify this Activity object, which implements the TabListener interface, as the // listener for when this tab is selected. actionBar.addTab(actionBar.newTab().setText(TitleNames[i]).setTabListener(this)); } actionBar.hide(); //mViewPager.setCurrentItem(tab.getPosition()) mViewPager.setCurrentItem(1); }