List of usage examples for android.app ActionBar addTab
@Deprecated public abstract void addTab(Tab tab);
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 w w .j av a 2 s. com*/ 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: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 www. 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)); } //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;// ww w .java 2 s. co 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.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 w w . j a va 2s . c om*/ 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.afollestad.overhear.ui.OverviewScreen.java
/** * Sets up the action bar tabs and the view pager. *///from w ww . jav a 2 s.c om private void setupTabs() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOffscreenPageLimit(5); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { getActionBar().setSelectedNavigationItem(position); } }); ActionBar.TabListener mTabListener = new ActionBar.TabListener() { @Override public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { } @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { invalidateOptionsMenu(); mViewPager.setCurrentItem(tab.getPosition()); } @Override public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { Fragment frag = getFragmentManager().findFragmentByTag("page:" + tab.getPosition()); if (frag instanceof ListFragment) { if (frag.getView() != null) ((ListFragment) frag).getListView().setSelection(0); } else if (frag instanceof OverhearGridFragment) { if (frag.getView() != null) ((OverhearGridFragment) frag).getListView().setSelection(0); } } }; for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) actionBar.addTab( actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(mTabListener)); actionBar.setSelectedNavigationItem(Store.i(this, "focused_tab", 2)); }
From source file:com.tabs.viewpager.testt.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 . ja v a2 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)); // } //adding tab 1 actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this)); //adding tab 2 actionBar.addTab(actionBar.newTab().setText(R.string.title_orders).setTabListener(this)); //adding tab 2 actionBar.addTab(actionBar.newTab().setText(R.string.title_my_profile).setTabListener(this)); }
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./*w ww. j av a 2s .c o 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:it.durip_app.MACActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_mac); data = new MACSource(); isIperfRunning = isIperfRunning();/* www. j av a 2 s. c om*/ isOlsrRunning = isOlsrRunning(); // Get the message from the intent Intent intent = getIntent(); paramUrl = intent.getStringExtra(MainActivity.PARAM_URL); paramT = intent.getIntExtra(MainActivity.PARAM_T, 200); paramI = intent.getIntExtra(MainActivity.PARAM_I, 5); paramMAC = intent.getStringExtra(MainActivity.PARAM_MAC); paramSleep = intent.getIntExtra(MainActivity.PARAM_SLEEP, 500); paramPort = intent.getIntExtra(MainActivity.PARAM_PORT, 4000); paramVerbose = intent.getIntExtra(MainActivity.PARAM_VERBOSE, 1); data.setUrl(paramUrl); data.setT(paramT); data.setI(paramI); data.setPort(paramPort); data.setSleep(paramSleep); data.setVerbose(paramVerbose); data.setMAC(paramMAC); // kick off the data generating thread: //mySource = new Thread(data); //mySource.start(); data.startMAC(); // 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.dvdprime.mobile.android.ui.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. 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 a 2s . 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); EasyTracker.getTracker().sendView(AppSectionsPagerAdapter.tabEngTitles[position]); LOGD("Tracker", AppSectionsPagerAdapter.tabEngTitles[position]); // Save position value in preference PrefUtil.getInstance().setInt(PrefKeys.LAST_TAB_POSITION, 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)); } // Google Analytics EasyTracker.getInstance().setContext(this); EasyTracker.getTracker().sendView("Main"); LOGD("Tracker", "Main"); // Set Last Tab lastPosition = PrefUtil.getInstance().getInt(PrefKeys.LAST_TAB_POSITION, 0); actionBar.setSelectedNavigationItem(lastPosition); // . if (PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null) != null) { JsonObjectRequest filterReq = new JsonObjectRequest( StringUtil.format(Config.MOBILE_DP_COUNT, PrefUtil.getInstance().getString(PrefKeys.ACCOUNT_ID, null)), null, createJsonReqSuccessListener(), createJsonReqErrorListener()); filterReq.setTag(TAG); DpApp.getRequestQueue().add(filterReq); } // ? if (SystemUtil.getVersionName(this).equals("1.0") && PrefUtil.getInstance().getBoolean(PrefKeys.VERSION_1_0, true)) { String msg = new StringBuffer().append("[1.0 ]\n\n").append( "-? \n ? ?? ? ? ?? /?.\n\n") .append("- \n ? ? ?. ? ? ?.") .toString(); new AlertDialog.Builder(this).setTitle(getString(R.string.alert_dialog_version)).setMessage(msg) .setCancelable(false) .setPositiveButton(getString(R.string.alert_dialog_ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { PrefUtil.getInstance().setBoolean(PrefKeys.VERSION_1_0, false); dialog.dismiss(); } }).create().show(); } }