List of usage examples for android.app ActionBar setNavigationMode
@Deprecated public abstract void setNavigationMode(@NavigationMode int mode);
From source file:com.ezevents.android.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cont = this;/*from www. j ava 2 s. com*/ intent = getIntent(); setContentView(R.layout.activity_main); mTitle = mDrawerTitle = getTitle(); mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens //mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_list_item, mPlanetTitles)); mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { @Override public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } @Override public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // 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 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. // // } String sec1 = "My Events"; String sec2 = "Popular Events"; String sec3 = "Notifications"; actionBar.addTab(actionBar.newTab().setText(sec1).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(sec2).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(sec3).setTabListener(this)); }
From source file:io.indy.drone.activity.StrikeDetailActivity.java
private void configureActionBar() { // Show the Up button in the action bar. ActionBar actionBar = getActionBar(); mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.locations_array, android.R.layout.simple_spinner_dropdown_item); mOnNavigationListener = new ActionBar.OnNavigationListener() { public boolean onNavigationItemSelected(int itemPosition, long itemId) { onRegionSelected(itemPosition); return true; }/*from w w w.ja v a 2s.co m*/ }; actionBar.setTitle(""); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); try { actionBar.setSelectedNavigationItem(SQLDatabase.indexFromRegion(mRegion)); } catch (Exception e) { e.printStackTrace(); } }
From source file:com.hardcopy.retrowatch.RetroWatchActivity.java
/***************************************************** * /*from w w w . java 2 s . c o m*/ * Overrided methods * ******************************************************/ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //----- System, Context mContext = this;//.getApplicationContext(); mActivityHandler = new ActivityHandler(); setContentView(R.layout.activity_retro_watch); // Load static utilities mUtils = new Utils(mContext); // 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 RetroWatchFragmentAdapter(mFragmentManager, mContext, this); // 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:it.durip_app.TCPActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_graph); data = new TCPSource(); // Get the message from the intent isIperfRunning = isIperfRunning();/*from ww w. j av a 2 s . com*/ Intent intent = getIntent(); paramUrl = intent.getStringExtra(MainActivity.PARAM_URL); paramT = intent.getIntExtra(MainActivity.PARAM_T, 200); paramI = intent.getIntExtra(MainActivity.PARAM_I, 5); paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000); paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500); paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1); // frequency = paramPort/1000; data.setUrl(paramUrl); data.setT(paramT); data.setI(paramI); data.setPort(paramPort); data.setSleep(paramSleep); data.setVerbose(paramVerbose); data.startTCP(); // kick off the data generating thread: /* mySource = new Thread(data); mySource.start(); */ // 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 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)); } // Show the Up button in the action bar. }
From source file:com.idevity.card.read.ReadMain.java
/** * Method onCreate./*from w w w . j av a 2 s.c o m*/ * * @param savedInstanceState * Bundle */ @TargetApi(19) @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_read_main); /* * We will take over the NFC Interface while in the foreground so there * is no additional read attempt. * * If on KitKat, we will set a filter and ignore any callbacks. */ /****************** Initialize NFC ******************/ if (debug) { Log.d(TAG, "Getting Adaptor..."); } NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this); /* * Platform version specific handling: KitKat */ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) { if (debug) { Log.d(TAG, "Setting Adaptor up for KitKat"); } ReaderCallback listener = new ReaderCallback() { public void onTagDiscovered(Tag tag) { /* * Discard the tags here */ tag = null; } }; int flags = NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK | NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS; adapter.enableReaderMode(this, listener, flags, null); } // Get preferences / settings that have been saved // get the show log this.sharedPref = PreferenceManager.getDefaultSharedPreferences(this); boolean showLog = this.sharedPref.getBoolean(g.getShowLog(), false); // Create the adapter that will return a fragment for each of the three // primary sections // of the app. mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager(), this.sharedPref); // 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(true); // 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); } }); /* * Use the following to determine content to show in the tabs. First, * check to see if there is an active intent Also, check to see if there * is an active saved instance state If, active intent - use active * intent; if active intent = null, and saved instance state !null, use * saved instance state; else return user to "main" instructions */ boolean hasIntent = false; boolean hasSavedData = false; try { if (getIntent().getExtras().getByteArray(g.getCardData()) != null) { hasIntent = true; } } catch (Throwable e) { Log.e(TAG, "Error: intent " + e.getMessage()); } try { if (g.getCard() != null) { hasSavedData = true; } } catch (Throwable e) { Log.e(TAG, "Error: saved instance state " + e.getMessage()); } // if intent, populate the variables with the intent values // else if saved instance, populate the same variables with the saved // instance state // else return user to read800-73 activity to read a new card if (hasIntent) { logStringBuffer = getIntent().getExtras().getString(g.getReaderLog()); byte[] _data = getIntent().getExtras().getByteArray(g.getCardData()); this.carddata = new CardData80073(_data); if (debug) { Log.d(TAG, "Using new card data"); } g.putCard(carddata.toByteArray()); g.putLogData(logStringBuffer); } else if (hasSavedData) { logStringBuffer = g.getLogData(); byte[] _data = g.getCard(); this.carddata = new CardData80073(_data); Log.e(TAG, "Using saved card data"); } else { Intent returnuser = new Intent(this, Read80073.class); startActivity(returnuser); Log.e(TAG, "No card data found; returning user to read a new card."); } /* * For each of the sections in the app, add a tab to the action bar. */ Tab tabA = actionBar.newTab(); tabA.setText(getString(R.string.TabRead_Title)); tabA.setTabListener(this); actionBar.addTab(tabA); // this one will become the CAK tab Tab tabB = actionBar.newTab(); tabB.setText(getString(R.string.TabCert_Title)); tabB.setTabListener(this); actionBar.addTab(tabB); // this one will become the CHUID tab Tab tabC = actionBar.newTab(); tabC.setText(getString(R.string.TabChuid_Title)); tabC.setTabListener(this); actionBar.addTab(tabC); // this one will become the APDU log tab // only set up the tab is the preferences for Show Log = True if (showLog) { Tab tabD = actionBar.newTab(); tabD.setText(getString(R.string.TabLog_Title)); tabD.setTabListener(this); actionBar.addTab(tabD); } }
From source file:ca.ramnansingh.randy.ibmwatsonspeechqa.AudioRecordTest.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Strictmode needed to run the http/wss request for devices > Gingerbread if (android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.GINGERBREAD) { StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); }//w w w .j a v a2s.c om //setContentView(R.layout.activity_main); setContentView(R.layout.activity_tab_text); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tabSTT = actionBar.newTab().setText("Speech to Text"); tabTTS = actionBar.newTab().setText("Text to Speech"); tabSTT.setTabListener(new MyTabListener(fragmentTabSTT)); tabTTS.setTabListener(new MyTabListener(fragmentTabTTS)); actionBar.addTab(tabSTT); actionBar.addTab(tabTTS); //actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#B5C0D0"))); }
From source file:com.packetsender.android.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); mContext = getApplicationContext();//w w w .j a va2 s.com serviceIntent = new Intent(mContext, PacketListenerService.class); activeMenu = R.menu.packetlistmenu; trafficLogPackets = new ArrayList<Packet>(); dataStore = new DataStorage(getSharedPreferences(DataStorage.PREFS_SETTINGS_NAME, 0), getSharedPreferences(DataStorage.PREFS_SAVEDPACKETS_NAME, 0), getSharedPreferences(DataStorage.PREFS_SERVICELOG_NAME, 0), getSharedPreferences(DataStorage.PREFS_MAINTRAFFICLOG_NAME, 0)); dataStore.clearServicePackets(); // 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 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)); } startListenerService(); wifiActive = DataStorage.isWifiActive(mContext); ipAddress = ""; if (wifiActive) { ipAddress = DataStorage.getIP(mContext); Toast.makeText(mContext, "Your IP is " + ipAddress, Toast.LENGTH_LONG).show(); } else { Toast.makeText(mContext, "Send only. Wifi is inactive.", Toast.LENGTH_LONG).show(); } //periodically poll the traffic log trafficLogPolling = new Runnable() { public void run() { String msg = dataStore.getToast(); if (!msg.isEmpty()) { Toast.makeText(mContext, msg, Toast.LENGTH_LONG).show(); } Packet[] trafficPackets = dataStore.fetchAllTrafficLogPackets(); if (trafficPackets.length != trafficLogPackets.size()) { trafficLogPackets.clear(); trafficLogPackets.addAll(Arrays.asList(trafficPackets)); updateTrafficPacketsList(trafficFragmentView); //trafficFragmentView } //Log.d("main", DataStorage.FILE_LINE( "trafficLogPolling.")); mHandler.postDelayed(trafficLogPolling, 1100); } }; //periodically monitor Wi-Fi updateWifi = new Runnable() { public void run() { boolean checkWifi = DataStorage.isWifiActive(mContext); if (checkWifi != wifiActive) { if (checkWifi) { ipAddress = DataStorage.getIP(mContext); Toast.makeText(mContext, "Your IP is " + ipAddress, Toast.LENGTH_LONG).show(); } else { Toast.makeText(mContext, "Wifi is not active", Toast.LENGTH_LONG).show(); } wifiActive = checkWifi; } mHandler.postDelayed(updateWifi, 5000); } }; mHandler.postDelayed(updateWifi, 5000); mHandler.postDelayed(trafficLogPolling, 700); //setup saved List periodic check updateSavedLists = new Runnable() { public void run() { if (dataStore.isInvalidateLists()) { Log.d("main", DataStorage.FILE_LINE("Found invalid lists.")); updateSavedPacketsList(packetsFragmentView); dataStore.clearInvalidateLists(); } mHandler.postDelayed(updateSavedLists, 2000); } }; mHandler.postDelayed(updateSavedLists, 7000); }
From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java
public void restoreActionBar() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayShowTitleEnabled(true); actionBar.setTitle(mTitle);// w w w. java 2 s . c o m actionBar.setIcon(mActionBarIcon); }
From source file:com.linkedin.android.eventsapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); pager = new ViewPager(this); pager.setId(R.id.pager);/*from w w w . j a va2 s . c o m*/ pager.setOffscreenPageLimit(5); setContentView(pager); final ActionBar bar = getActionBar(); View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null); TextView textviewTitle = (TextView) viewActionBar.findViewById(R.id.actionbar_textview); ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER); textviewTitle.setText("UPCOMING EVENTS"); bar.setCustomView(viewActionBar, params); bar.setDisplayShowCustomEnabled(true); bar.setDisplayShowTitleEnabled(false); bar.setIcon(new ColorDrawable(Color.TRANSPARENT)); bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153"))); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mEventTabsAdapter = new com.linkedin.android.eventsapp.EventTabsAdapter(this, pager); SimpleDateFormat ft = new SimpleDateFormat("E dd MMM"); ArrayList<Event> events = EventsManager.getInstance(this).getEvents(); for (Event event : events) { String eventDay = ft.format(new Date(event.getEventDate())); mEventTabsAdapter.addTab(bar.newTab().setText(eventDay), EventFragment.class, event); } }
From source file:de.da_sense.moses.client.WelcomeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate() called"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); thisInstance = this; mAppSectionsPagerAdapter = new WelcomeActivityPagerAdapter(getSupportFragmentManager(), this); // get ActionBar and set NavigationMode 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/* w w w. j a va 2s.c o m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); 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)); } // Moses got called to view a UserStudy boolean isShowUserStudyCall = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID) != null; if (isShowUserStudyCall) { onLoginCompleteShowUserStudy = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID); } if (!isLoginInformationComplete(this) && !waitingForResult) { // Here, the activity is called to display the login screen, and, // when filled in, redirect the user to the user study that was // meant to be displayed originally waitingForResult = true; // set flag that on login credentials arrival show a user study // set the deviceID in the SharedPreferences before attempting to // login String theDeviceID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); PreferenceManager.getDefaultSharedPreferences(this).edit() .putString(MosesPreferences.PREF_DEVICEID, theDeviceID).commit(); Intent loginDialog = new Intent(WelcomeActivity.this, LoginActivity.class); startActivityForResult(loginDialog, 1); } if (HistoryExternalApplicationsManager.getInstance() == null) { HistoryExternalApplicationsManager.init(this); } if (InstalledExternalApplicationsManager.getInstance() == null) { InstalledExternalApplicationsManager.init(this); } if (UserstudyNotificationManager.getInstance() == null) { UserstudyNotificationManager.init(this); } // initialize the UI elements initControls(savedInstanceState); }