List of usage examples for android.app ActionBar setSelectedNavigationItem
@Deprecated public abstract void setSelectedNavigationItem(int position);
From source file:com.dooweb.flip.TestProfile.java
public void onCreate(Bundle savedInstanceState) { Log.v("profile", "create"); super.onCreate(savedInstanceState); Log.v("profile", "super"); setContentView(R.layout.test_profile); // Create the adapter that will return a fragment for each of the three primary sections // of the app. Log.v("profile", "new adapter"); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar. Log.v("profile", "actionbar"); final ActionBar actionBar = getActionBar(); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./*from w ww. j a va 2 s. c o m*/ Log.v("profile", "homebutton"); actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. Log.v("profile", "setnav"); 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. Log.v("profile", "viewpager"); 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:capsrock.beta.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); timeSheet = new TimeSheet(); PebbleData = new PebbleDictionary(); //Set up to Receive messages from the pebble and handle them correctly PebbleKit.registerReceivedDataHandler(this, new PebbleKit.PebbleDataReceiver(PEBBLE_APP_UUID) { @Override/* w ww .j a v a 2s . c om*/ public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) { String mode = data.getString(1); //((TextView)findViewById(R.id.pebbleText)).setText(mode); if (mode.substring(9).equals("Break") || mode.substring(9).equals("Work")) { ((TimeEntryFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":0")) .onTimeEntry(findViewById(R.id.StartButton), false); } else { ((TimeEntryFragment) getSupportFragmentManager() .findFragmentByTag("android:switcher:" + R.id.pager + ":0")) .onTimeEntry(findViewById(R.id.StopButton), false); } PebbleKit.sendAckToPebble(getApplicationContext(), transactionId); } }); //Set up the timer thread thr = new Thread(new Runnable() { @Override public void run() { while (true) { try { Thread.sleep(1000); mHandler.post(new Runnable() { @Override public void run() { Message mes = new Message(); if (strDate != null) { long seconds = Calendar.getInstance().getTimeInMillis() - strDate.getTimeInMillis(); long minutes = seconds / 1000 / 60; minutes %= 60; long hours = seconds / 1000 / 60 / 60; hours %= 24; seconds /= 1000; seconds %= 60; String sec = hours + ":" + minutes + ":" + seconds; mes.obj = sec; mHandler.sendMessage(mes); } else { mes.obj = "00:00:00"; mHandler.sendMessage(mes); } } }); } catch (Exception e) { } } } }); //Start Login Screen Intent intent = new Intent(); intent.setClassName("capsrock.beta", "capsrock.beta.LoginActivity"); //startActivity(intent); 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. // 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++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:edu.tcfsh.arrivinglaterecordapp.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main_activity); getBundle();/* w w w. jav a 2s . c om*/ arrivingLateRecordFragment = new ArrivingLateRecordFragment(dayOfMonth, month, year); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); leavingActivityDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); leavingActivityDialog.setTitle("??"); leavingActivityDialog.setMessage("?"); leavingActivityDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { savingFileAlertDialog.show(); } }); leavingActivityDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { } }); savingFileAlertDialog = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_LIGHT); savingFileAlertDialog.setTitle("??"); savingFileAlertDialog.setMessage("?????"); savingFileAlertDialog.setPositiveButton("", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { arrivingLateRecordFragment.saveArrivingLateRecordFile(); finish(); } }); savingFileAlertDialog.setNegativeButton("?", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { finish(); } }); // 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 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:no.invisibleink.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* -------------------------------- Init ---------------- */ serverManager = new ServerManager(); locationManager = new LocationManager(this); locationManager.onCreate();/* w w w .j a v a 2 s . co m*/ /* -------------------------------- Swipe view with taps ---------------- */ fragmentManager = getSupportFragmentManager(); listSectionFragment = new ListViewFragment(); mapSectionFragment = new MapViewFragment(); postSectionFragment = new PostViewFragment(); // Create the adapter that will return a fragment for each of the three primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(fragmentManager); // 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 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); } }); /* * Set the number of pages that should be retained to either side of the * current page in the view hierarchy in an idle state. Pages beyond * this limit will be recreated from the adapter when needed. */ mViewPager.setOffscreenPageLimit(3); // 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)); } try { MapsInitializer.initialize(getApplicationContext()); } catch (GooglePlayServicesNotAvailableException e) { Log.e(TAG, "Google play services is not available."); } }
From source file:com.hardcopy.arduinonavi.MainActivity.java
/***************************************************** * Overrided methods// w w w . j a v a 2 s. c o m ******************************************************/ @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 mNaviInfo = (TextView) findViewById(R.id.status_navi_info); mNaviInfo.setText(getResources().getString(R.string.title_destination) + ": "); mNaviMode = (Button) findViewById(R.id.btn_mode); mNaviMode.setOnClickListener(this); showUnitTypeButton(); 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:it.personal.keyring.SetupActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_setup); // 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//from ww w .ja v a 2s. c o 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:uk.bowdlerize.MainActivity.java
private void configureTabs() { // 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 activity. mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); // 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// w w w .j a v a 2s . c o 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.nononsenseapps.notepad.MainActivity.java
/** * This is meant to be called from the intent handling. It handles the two * possible cases that this app was already running when it received the * intent or it was started fresh with the intent meaning we have to handle * the opening asynchronously./* ww w . j av a2 s .c o m*/ * * @param listId */ private void openListFromIntent(long listId, Intent intent) { if (beforeBoot) { // Set the variable to be selected after the loader has // finished its query listIdToSelect = listId; noteIntentToSelect = intent; Log.d(TAG, "beforeBoot setting future id"); } else { // Select the list directly since the loader is done int pos = getPosOfId(listId); Log.d("FragmentLayout", "pos: " + pos); if (pos > -1) { // select it ActionBar ab = getActionBar(); if (ab != null && ab.getSelectedNavigationIndex() != pos) { ab.setSelectedNavigationItem(pos); } NotesListFragment list = getLeftFragment(); if (list != null) { list.handleNoteIntent(intent); } } } }
From source file:edu.pdx.cecs.orcycle.TabsConfig.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); try {//from www.j av a 2s . c o m myApp = MyApplication.getInstance(); myApp.setRunning(true); myApp.clearReminderNotifications(); setContentView(R.layout.tabs_config); Log.v(MODULE_TAG, "Cycle: TabsConfig onCreate"); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Toast.makeText(this, "Tab Created", Toast.LENGTH_LONG).show(); fragment1 = new FragmentMainInput(); fragment2 = new FragmentSavedTripsSection(); fragment3 = new FragmentSavedNotesSection(); //fragment4 = new FragmentUserInfo(); fragment4 = new FragmentSettings(); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setBackgroundDrawable(getResources().getDrawable(R.color.psu_green)); // Create the adapter that will return a fragment for each of the four // 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 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)); } mViewPager.setOffscreenPageLimit(4); Intent intent; Bundle bundle; if (null != (intent = getIntent())) { if (null != (bundle = intent.getExtras())) { fragmentToShow = bundle.getInt(TabsConfig.EXTRA_SHOW_FRAGMENT, FRAG_INDEX_MAIN_INPUT); } } } catch (Exception ex) { Log.e(MODULE_TAG, ex.getMessage()); } }
From source file:com.tweetlanes.android.core.view.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { AccountDescriptor account = getApp().getCurrentAccount(); Bundle extras = getIntent().getExtras(); if (extras != null) { // Notifications String accountKey = extras.getString("account_key"); String notificationType = extras.getString("notification_type"); long notificationPostId = extras.getLong("notification_post_id"); String laneName = extras.getString("lane"); final String urlToLoad = extras.getString("urlToLoad"); if (accountKey != null) { getIntent().removeExtra("account_key"); getIntent().removeExtra("notification_type"); AccountDescriptor notificationAccount = getApp().getAccountByKey(accountKey); Notifier.saveLastNotificationActioned(this, accountKey, notificationType, notificationPostId); Constant.LaneType notificationLaneType = notificationType.equals( SharedPreferencesConstants.NOTIFICATION_TYPE_MENTION) ? Constant.LaneType.USER_MENTIONS : Constant.LaneType.DIRECT_MESSAGES; if (notificationAccount != null) { long notificationAccountId = notificationAccount.getId(); long currentAccountId = account.getId(); if (notificationAccountId == currentAccountId) { int index = account.getCurrentLaneIndex(notificationLaneType); if (index > -1) { mDefaultLaneOverride = index; }/*w ww . j a v a2s .c o m*/ } else { showAccount(notificationAccount, notificationLaneType); } } } else if (laneName != null) { getIntent().removeExtra("lane"); int index = account.getCurrentLaneIndex(Constant.LaneType.valueOf(laneName.trim().toUpperCase())); if (index > -1) { mDefaultLaneOverride = index; } } else if (urlToLoad != null) { getIntent().removeExtra("urlToLoad"); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setMessage(getString(R.string.unknown_intent)); alertDialogBuilder.setPositiveButton(getString(R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { Intent viewIntent = new Intent("android.intent.action.VIEW", Uri.parse(urlToLoad.trim())); startActivity(viewIntent); } }); alertDialogBuilder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); alertDialogBuilder.create().show(); } } super.onCreate(savedInstanceState); // Attempt at fixing a crash found in HomeActivity if (account == null) { Toast.makeText(getApplicationContext(), "No cached account found, restarting", Constant.DEFAULT_TOAST_DISPLAY_TIME).show(); restartApp(); return; } ActionBar actionBar = getActionBar(); actionBar.setDisplayUseLogoEnabled(true); actionBar.setTitle(null); actionBar.setDisplayShowTitleEnabled(false); mSpinnerAdapter = new AccountAdapter(this, getApp().getAccounts()); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); actionBar.setSelectedNavigationItem(0); onCreateNavigationListener(); configureListNavigation(); mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher); updateViewVisibility(); onCreateHandleIntents(); account.setDisplayedLaneDefinitionsDirty(false); Notifier.setNotificationAlarm(this); clearTempFolder(); cacheFollowers(); //Launch change log dialog final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this); whatsNewDialog.show(); }