List of usage examples for android.app ActionBar setSelectedNavigationItem
@Deprecated public abstract void setSelectedNavigationItem(int position);
From source file:app.hacked.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); //getActionBar().setIcon(R.drawable.ic_ab_logo); actionBar.setSubtitle("This app is UNOFFICIAL"); queue = Volley.newRequestQueue(this); // 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 w ww .ja va 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)); } //GCM stuff GCMRegistrar.checkDevice(this); GCMRegistrar.checkManifest(this); regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { Log.v("GCM", "Registering"); GCMRegistrar.register(this, API.SENDER_ID); } else { Log.v("GCM", "Already registered"); } //Log.e("GCMID",GCMRegistrar.getRegistrationId(this)); JSONObject post = new JSONObject(); try { post.put("gcmid", regId); post.put("deviceid", Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID)); } catch (Exception e) { e.printStackTrace(); Toast.makeText(this, "An Error Was encountered connecting to the GCM cloud. Chat will be unavailable", Toast.LENGTH_LONG).show(); return; } JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.POST, "http://hackedioapp.networksaremadeofstring.co.uk/registergcm.php", post, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { Log.e("response", response.toString()); try { if (response.has("success") && response.getBoolean("success")) { //Alls cool } } catch (Exception e) { e.printStackTrace(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { // TODO Auto-generated method stub } }); queue.add(jsObjRequest); }
From source file:dk.bearware.gui.AudioCodecActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_audiocodec); audiocodec = Utils.getAudioCodec(this.getIntent()); int tab_index = 0; switch (audiocodec.nCodec) { case Codec.OPUS_CODEC: opuscodec = audiocodec.opus;//from w w w . j ava 2 s . c o m tab_index = TAB_OPUS; break; case Codec.SPEEX_CODEC: speexcodec = audiocodec.speex; tab_index = TAB_SPEEX; break; case Codec.SPEEX_VBR_CODEC: speexvbrcodec = audiocodec.speex_vbr; tab_index = TAB_SPEEXVBR; break; case Codec.NO_CODEC: tab_index = TAB_NOAUDIO; break; } // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // 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)); } mViewPager.setCurrentItem(tab_index); }
From source file:it.durip_app.GraphActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_graph); data = new DataSource(); // Get the message from the intent Intent intent = getIntent();/*from w ww . ja v a 2 s .c o m*/ String paramUrl = intent.getStringExtra(MainActivity.PARAM_URL); int paramT = intent.getIntExtra(MainActivity.PARAM_T, 200); int paramI = intent.getIntExtra(MainActivity.PARAM_I, 5); int paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000); int paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1); data.setUrl(paramUrl); data.setT(paramT); data.setI(paramI); data.setPort(paramPort); data.setVerbose(paramVerbose); // 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.ezevents.android.app.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); cont = this;/*from w w w.ja va 2s .c o m*/ 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: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 w ww . j a v a2 s .c o m 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.example.swipeuiforupclose.MainActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.profile_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 ww . j av a 2s .co m actionBar.setHomeButtonEnabled(false); actionBar.setBackgroundDrawable(new ColorDrawable(0xFF46304e)); actionBar.setStackedBackgroundDrawable(new ColorDrawable(0xFF573d5d)); actionBar.setTitle("My Profile"); // Specify that we will be displaying tabs in the action bar. //actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 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.tweetlanes.android.core.view.HomeActivity.java
private boolean configureListNavigation() { if (mSpinnerAdapter == null) { return false; }/*from w ww . ja v a2s.co m*/ ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); int accountIndex = 0; AccountDescriptor currentAccount = getApp().getCurrentAccount(); if (currentAccount != null) { for (int i = 0; i < getApp().getAccounts().size(); i++) { if (currentAccount.getAccountKey().equals(getApp().getAccounts().get(i).getAccountKey())) { accountIndex = i; break; } } } actionBar.setSelectedNavigationItem(accountIndex); actionBar.setDisplayHomeAsUpEnabled(false); return true; }
From source file:com.tweetlanes.android.view.HomeActivity.java
private boolean configureListNavigation() { if (mSpinnerAdapter == null) { return false; }/*from w ww . jav a 2s. c om*/ ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(android.app.ActionBar.NAVIGATION_MODE_LIST); actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener); int accountIndex = 0; AccountDescriptor currentAccount = getApp().getCurrentAccount(); if (currentAccount != null) { String testScreenName = "@" + currentAccount.getScreenName().toLowerCase(); for (int i = 0; i < mAdapterStrings.length; i++) { if (testScreenName.equals(mAdapterStrings[i].toLowerCase())) { accountIndex = i; break; } } } actionBar.setSelectedNavigationItem(accountIndex); actionBar.setDisplayHomeAsUpEnabled(false); return true; }
From source file:com.hardcopy.retrowatch.RetroWatchActivity.java
/***************************************************** * //from ww w . j a va2 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:com.plnyyanks.frcnotebook.activities.ViewTeam.java
@Override protected void onCreate(Bundle savedInstanceState) { setTheme(PreferenceHandler.getTheme()); super.onCreate(savedInstanceState); setContentView(R.layout.activity_view_team); activity = this; ActionBar bar = getActionBar(); bar.setTitle(teamNumber != -1 ? "Team " + teamNumber : "All Data"); //tab for team overview ActionBar.Tab teamOverviewTab = bar.newTab(); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); teamOverviewTab.setText("All Notes"); teamOverviewTab.setTag("all"); teamOverviewTab.setTabListener(this); bar.addTab(teamOverviewTab);//from w w w .j a v a 2s.c o m bar.setDisplayHomeAsUpEnabled(true); //add an actionbar tab for every event the team is competing at ArrayList<String> events; if (teamNumber == -1) { events = StartActivity.db.getAllEventKeys(); } else { Team team = StartActivity.db.getTeam(teamKey); events = team.getTeamEvents(); } for (String eventKey : events) { Log.d(Constants.LOG_TAG, "Making AB Tab for " + eventKey); Event event = StartActivity.db.getEvent(eventKey); if (event == null) continue; ActionBar.Tab eventTab = bar.newTab(); eventTab.setTag(event.getEventKey()); eventTab.setText(event.getShortName()); eventTab.setTabListener(this); bar.addTab(eventTab); } if (savedInstanceState != null) { bar.setSelectedNavigationItem(savedInstanceState.getInt(STATE_SELECTED_NAVIGATION_ITEM, 0)); } else { bar.setSelectedNavigationItem(0); } }