List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:org.ado.minesync.gui.MineSyncMainActivity.java
/** * Called when the activity is first created. * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in onSaveInstanceState(Bundle). <b>Note: Otherwise it is null.</b> *//* w w w .j a v a2s . co m*/ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ALog.d(TAG, "onCreate. savedInstanceState [" + savedInstanceState + "]."); setContentView(R.layout.activity_main); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getApplicationContext(), getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } accountManager = getDropboxAccountManager(getApplicationContext()); activityTracker = new ActivityTracker(getApplicationContext()); minecraftDropboxStatus = new MinecraftDropboxStatus(this); upgradeManager = new UpgradeManager(getApplicationContext()); upgradeManager.upgradeIfNeeded(); startServicesIfNeeded(); ALog.d(TAG, "var configProcessActive [" + configProcessActive + "]"); }
From source file:com.otaupdater.TabDisplay.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Context context = getApplicationContext(); cfg = Config.getInstance(context);// w w w .j a v a 2 s. c o m if (!Utils.haveProKey(context)) { cfg.setKeyExpiry(0); } else if (!cfg.hasValidProKey()) { if (cfg.isProKeyTemporary()) { if (cfg.getKeyExpires() < System.currentTimeMillis()) { Utils.verifyProKey(context); } } else { Utils.verifyProKey(context); } } if (!Utils.isRomOtaEnabled() && !Utils.isKernelOtaEnabled()) { if (!cfg.getIgnoredUnsupportedWarn()) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(R.string.alert_unsupported_title); alert.setMessage(R.string.alert_unsupported_message); alert.setCancelable(false); alert.setNegativeButton(R.string.alert_exit, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alert.setPositiveButton(R.string.alert_ignore, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { cfg.setIgnoredUnsupportedWarn(true); dialog.dismiss(); } }); alert.create().show(); } if (Utils.marketAvailable(this)) { GCMRegistrar.checkDevice(context); GCMRegistrar.checkManifest(context); final String regId = GCMRegistrar.getRegistrationId(context); if (regId.length() != 0) { GCMRegistrar.unregister(context); } } } else { if (Utils.marketAvailable(this)) { GCMRegistrar.checkDevice(context); GCMRegistrar.checkManifest(context); final String regId = GCMRegistrar.getRegistrationId(context); if (regId.length() != 0) { if (cfg.upToDate()) { Log.v(Config.LOG_TAG + "GCMRegister", "Already registered"); } else { Log.v(Config.LOG_TAG + "GCMRegister", "Already registered, out-of-date"); cfg.setValuesToCurrent(); new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { Utils.updateGCMRegistration(context, regId); return null; } }.execute(); } } else { GCMRegistrar.register(context, Config.GCM_SENDER_ID); Log.v(Config.LOG_TAG + "GCMRegister", "GCM registered"); } } else { UpdateCheckReceiver.setAlarm(context); } } mViewPager = new ViewPager(this); mViewPager.setId(R.id.pager); setContentView(mViewPager); final ActionBar bar = getActionBar(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE); bar.setTitle(R.string.app_name); mTabsAdapter = new TabsAdapter(this, mViewPager); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_rom), ROMTab.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_kernel), KernelTab.class, null); mTabsAdapter.addTab(bar.newTab().setText(R.string.main_walls), WallsTab.class, null); if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0)); } }
From source file:com.f8full.casserolesencours.CasserolesEnCoursV2.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 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// www .java 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)); } try { // initialize the transport httpTransport = new NetHttpTransport(); // authorization //Credential credential = new Credential(); // set up global Fusiontables instance client = new Fusiontables.Builder(httpTransport, JSON_FACTORY, null) .setApplicationName(APPLICATION_NAME).build(); //System.out.println("Success! Now add code here."); String fromTableID = "1cmlx9aChHUYTWwYivaZucr7NHNsP_ulvEPX1FoM"; Sql sql = client.query().sql("SELECT * FROM " + fromTableID); new ViewerSetupTask().execute(sql); } catch (IOException e) { System.err.println(e.getMessage()); } catch (Throwable t) { t.printStackTrace(); } }
From source file:com.joncairo.android.todo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set up the main activity view to be populated with fragments. setContentView(R.layout.activity_main); // Set up the action bar for tabs final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter to manage tab switching 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 w w w.j a v a 2 s .c om 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)); } // Wire up the to do text entry field mNewToDoName = (EditText) findViewById(R.id.todo_text); mNewToDoName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { DataLoader dataLoader = new DataLoader(getBaseContext(), mDataFileName); dataLoader.setTextInputData(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); // Wire up the to do enter button Button mDoIt = (Button) findViewById(R.id.enter_button); mDoIt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<Todo> mToDoToBeAdded = new ArrayList<Todo>(); String newToDoText = setInputText(); // Create a new todo instance Todo newTodo = new Todo(newToDoText); mToDoToBeAdded.add(newTodo); // delete the text //mNewToDoName.setText(""); // append it to the todolist array mtoDoFragment.addItemsToList(mToDoToBeAdded, ""); } }); }
From source file:com.lifestats.MainActivity.java
/** * onCreate: Setup Tab structure and Action Bar. * * @param savedInstanceState saved instance state. */// www . j ava2s . c o m @Override public void onCreate(Bundle savedInstanceState) { /** * Routine create view. */ super.onCreate(savedInstanceState); setContentView(R.layout.main); /** * Setup the ViewPager and its Adapter. */ PagerAdapter mPagerAdapter = new ScreenSlidePagerAdapter(getFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter); mPager.setOffscreenPageLimit(0); /** * Change selected ActionBar title when swipe left or right. */ mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @SuppressWarnings("ConstantConditions") @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); /** * Setup ActionBar displaying the Tab titles. */ final ActionBar actionBar = getActionBar(); assert actionBar != null; actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); /** * Setup TabListener to display the correct tab content. */ ActionBar.TabListener tabListener = new ActionBar.TabListener() { public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { mPager.setCurrentItem(tab.getPosition()); } public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { } }; /** * Add the actual Tabs to the page. * 1. Record activity tab. * 2. Show activity tab. */ ActionBar.Tab recordTab = actionBar.newTab(); recordTab.setText(R.string.recordActivities); recordTab.setTabListener(tabListener); actionBar.addTab(recordTab); ActionBar.Tab showTab = actionBar.newTab(); showTab.setText(R.string.showActivities); showTab.setTabListener(tabListener); actionBar.addTab(showTab); }
From source file:com.ibm.msg.android.ConnectionDetails.java
/** * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle) *///from w w w.j a va 2 s .c o m @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); clientHandle = getIntent().getStringExtra("handle"); setContentView(R.layout.activity_connection_details); // Create the adapter that will return a fragment for each of the pages sectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); // Set up the action bar for tab navigation final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // add the sectionsPagerAdapter viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(sectionsPagerAdapter); viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // select the tab that represents the current page actionBar.setSelectedNavigationItem(position); } }); // Create the tabs for the screen for (int i = 0; i < sectionsPagerAdapter.getCount(); i++) { ActionBar.Tab tab = actionBar.newTab(); tab.setText(sectionsPagerAdapter.getPageTitle(i)); tab.setTabListener(this); actionBar.addTab(tab); } connection = Connections.getInstance(this).getConnection(clientHandle); changeListener = new ChangeListener(); connection.registerChangeListener(changeListener); }
From source file:net.sf.diningout.app.ui.RestaurantsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar ab = getActionBar(); ab.setDisplayShowTitleEnabled(false); ab.setNavigationMode(NAVIGATION_MODE_LIST); ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.restaurants_navigation, R.id.sort, res().getStringArray(R.array.restaurants_sort)); adapter.setDropDownViewResource(R.layout.restaurants_navigation_item); ab.setListNavigationCallbacks(adapter, this); ab.setSelectedNavigationItem(mSort); // restore when rotating with navigation drawer open setContentView(R.layout.restaurants_activity); if (mDrawerLayout != null) { setDrawerLayout(mDrawerLayout);/*from ww w . ja v a2 s . c o m*/ } /* set up the map if it was previously showing */ MapFragment map = map(); if (map != null) { map.getMapAsync(this); } getLoaderManager().initLoader(0, null, this); // need already to support config changes }
From source file:dude.morrildl.weatherport.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // We store the list of airports the user has expressed interest in in // SharedPrefs, as a list (well, Set) of Strings SharedPreferences prefs = getSharedPreferences("prefs", Context.MODE_PRIVATE); Set<String> currentSet = prefs.getStringSet("airports", null); if (currentSet == null || currentSet.size() < 1) { // i.e. first run -- hard-default KSFO to the list HashSet<String> defaultSet = new HashSet<String>(); defaultSet.add("KSFO"); prefs.edit().putStringSet("airports", defaultSet).commit(); currentSet = defaultSet;//from w ww . j a v a 2 s . co m } // enable the nav spinner, which we'll use to pick which airport to look // at ActionBar bar = getActionBar(); bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); ArrayList<String> currentList = new ArrayList<String>(); currentList.addAll(currentSet); Collections.sort(currentList); adapter = new ArrayAdapter<CharSequence>(bar.getThemedContext(), android.R.layout.simple_spinner_dropdown_item); adapter.addAll(currentList); bar.setListNavigationCallbacks(adapter, new OnNavigationListener() { @Override public boolean onNavigationItemSelected(int arg0, long arg1) { // this re-ups the data whenever the user changes the current // airport startAsyncFetch(adapter.getItem(arg0).toString()); return true; } }); // Let's set up a fancy new v2 MapView, for the lulz mapFragment = new SupportMapFragment(); pagerAdapter = new TwoFragmentPagerAdapter(this, getSupportFragmentManager(), new DetailsFragment(), mapFragment); viewPager = (ViewPager) findViewById(R.id.pager); viewPager.setAdapter(pagerAdapter); viewPager.setOnPageChangeListener(this); // No placemarker on the map because I've always secretly hated that // glyph }
From source file:com.reliqartz.firsttipcalc.gui.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); loadPreferences();/*from w ww. j ava 2 s. c om*/ // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // initialize fragments if (savedInstanceState == null) { mCalculator = new CalcFragment(); mSplitter = new SplitterFragment(); } else { mCalculator = (CalcFragment) getSupportFragmentManager().getFragment(savedInstanceState, CalcFragment.TAG); mSplitter = (SplitterFragment) getSupportFragmentManager().getFragment(savedInstanceState, SplitterFragment.TAG); } // Create the adapter that will return a fragment for each of the three // primary sections of the application. 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)); } // setup fonts applyFonts(); }
From source file:com.github.riotopsys.malforandroid2.activity.HubActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.i(TAG, "onCreate"); setContentView(R.layout.main);//from w w w. j a v a 2 s. co m ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar .setListNavigationCallbacks( new ArrayAdapter<String>(actionBar.getThemedContext(), android.R.layout.simple_list_item_1, android.R.id.text1, getResources().getStringArray(R.array.drop_down_nav_options)), this); setupAnimeAdapter(); setupMangaAdapter(); if (!state.isSyncScheduled()) { //somehow we hit this point with out starting the sync, so we'll do it now BootReciever.scheduleSync(state, this); } if (detailFrame != null) { transitionDetail(false); } if (savedInstanceState != null) { actionBar.setSelectedNavigationItem(savedInstanceState.getInt("MODE")); } apprater.onAppOpened(this); }