Example usage for android.app ActionBar NAVIGATION_MODE_TABS

List of usage examples for android.app ActionBar NAVIGATION_MODE_TABS

Introduction

In this page you can find the example usage for android.app ActionBar NAVIGATION_MODE_TABS.

Prototype

int NAVIGATION_MODE_TABS

To view the source code for android.app ActionBar NAVIGATION_MODE_TABS.

Click Source Link

Document

Tab navigation mode.

Usage

From source file:scmu.nutweet.bluetooth.BluetoothChat.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (D)/*w  ww  . j a  v a  2  s. co m*/
        Log.e(TAG, "+++ ON CREATE +++");

    // Set up the window layout
    setContentView(R.layout.activity_chat);

    // Set up the action bar to show tabs.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // For each of the sections in the app, add a tab to the action bar.
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.friends_black).setTabListener(this));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.chatmsg_black).setTabListener(this));

    //stateChange(Const.mService.getState());
}

From source file:org.ounl.lifelonglearninghub.nfcecology.swipe.SwipeActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe);

    // 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();
    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/*from   w ww  . j  av  a 2  s  .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);
        }
    });

    // 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:org.kanbansalad.scanner.client.android.ScanActivity.java

private void addTabsToActionBar() {
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    configureViewPager();/*from   w w w.  j  ava  2s .c o m*/
    enableSwipeToMoveBetweenTabs(actionBar);

    addTabsTo(actionBar);
}

From source file:net.seedboxer.seedroid.activities.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);

    setContentView(R.layout.main_activity_view);

    // 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 a v a2  s  . c om
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mViewPager = (ViewPager) findViewById(R.id.pager);

    mAppSectionsPagerAdapter = new TabsAdapter(this, getSupportFragmentManager(), mViewPager);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_inprogres),
            StatusFragment.class, null);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_queue), InQueueFragment.class,
            null);
    mAppSectionsPagerAdapter.addTab(actionBar.newTab().setText(R.string.tab_title_downloads),
            DownloadsFragment.class, null);

    if (savedInstanceState != null) {
        actionBar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }

    GCMRegistrar.checkManifest(this);
    GCMRegistrar.checkDevice(this);
}

From source file:edu.rutgers.winlab.crowdpp.ui.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main_activity_layout);

    // 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  ww  .ja  v a2s. 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);
        }
    });

    // 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));
    }

    SharedPreferences settings = this.getSharedPreferences("config", Context.MODE_PRIVATE);
    ;
    SharedPreferences.Editor editor = settings.edit();

    // load the default parameters into SharedPreferences for the first time launch 
    int ct = settings.getInt("count", 0);
    if (ct == 0) {
        editor.putString("start", "9");
        editor.putString("end", "21");
        editor.putString("interval", "15");
        editor.putString("duration", "5");
        editor.putString("location", "On");
        editor.putString("upload", "On");
        TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
        editor.putString("IMEI", tm.getDeviceId());
        editor.putString("brand", Build.BRAND);
        editor.putString("model", Build.MODEL);
        String phone_type = Build.BRAND + "_" + Build.MODEL;

        // motoX
        if (phone_type.equals("motorola_XT1058")) {
            editor.putString("mfcc_dist_same_semi", "13");
            editor.putString("mfcc_dist_diff_semi", "18");
            editor.putString("mfcc_dist_same_un", "13");
            editor.putString("mfcc_dist_diff_un", "18");
        }
        // nexus 4
        else if (phone_type.equals("google_Nexus 4")) {
            editor.putString("mfcc_dist_same_semi", "17");
            editor.putString("mfcc_dist_diff_semi", "22");
            editor.putString("mfcc_dist_same_un", "17");
            editor.putString("mfcc_dist_diff_un", "22");
        }
        // s2
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I727")) {
            editor.putString("mfcc_dist_same_semi", "18");
            editor.putString("mfcc_dist_diff_semi", "25");
            editor.putString("mfcc_dist_same_un", "18");
            editor.putString("mfcc_dist_diff_un", "25");
        }
        // s3 
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I747")) {
            editor.putString("mfcc_dist_same_semi", "16");
            editor.putString("mfcc_dist_diff_semi", "21");
            editor.putString("mfcc_dist_same_un", "16");
            editor.putString("mfcc_dist_diff_un", "21");
        }
        // s4
        else if (phone_type.equals("samsung_SAMSUNG-SGH-I337")) {
            editor.putString("mfcc_dist_same_semi", "14");
            editor.putString("mfcc_dist_diff_semi", "24");
            editor.putString("mfcc_dist_same_un", "14");
            editor.putString("mfcc_dist_diff_un", "24");
        }
        // other devices
        else {
            editor.putString("mfcc_dist_same_semi", "15.6");
            editor.putString("mfcc_dist_diff_semi", "21.6");
            editor.putString("mfcc_dist_same_un", "15.6");
            editor.putString("mfcc_dist_diff_un", "21.6");
            Toast.makeText(this, "Your device is not recognized and the result might not be accurate...",
                    Toast.LENGTH_SHORT).show();
        }
        Log.i("Crowd++", "First time launched");

        AlertDialog dialog = new AlertDialog.Builder(this).create();
        dialog.setTitle("Welcome to Crowd++");
        dialog.setMessage(Constants.hello_msg);
        dialog.setButton(AlertDialog.BUTTON_POSITIVE, "Close", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();
        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setTextSize(20);
    }

    editor.putInt("count", ++ct);
    editor.commit();
    Log.i("Launched Count", Integer.toString(ct));
    mConst = new Constants(this);
    if (!Constants.calibration())
        Toast.makeText(this, "You haven't calibrated the system.", Toast.LENGTH_SHORT).show();
}

From source file:org.ounl.lifelonglearninghub.nfclearntracker.swipe.SwipeActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_swipe);

    // 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  ww  w  .j a  v a2s  . c om
    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:com.ibm.msg.android.ConnectionDetails.java

/**
 * @see android.support.v4.app.FragmentActivity#onCreate(android.os.Bundle)
 *///from   ww w .  ja  v  a 2s.  com
@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:au.com.runecasters.volumescheduler.app.RuleActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rule);
    mButtonCreateRule = (Button) findViewById(R.id.buttonCreateRule);

    mSchedulerRule = getIntent().getParcelableExtra("existingRule");
    if (mSchedulerRule == null) {
        mSchedulerRule = new SchedulerRule(getIntent().getIntExtra("selector", -1));
        mNewRule = true;//from w  w  w . ja v  a  2 s.co  m
    }

    // 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));
    }

    mButtonCreateRule.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
                ScheduleRuleSetter ruleFragment = (ScheduleRuleSetter) mSectionsPagerAdapter.getItem(i);
                ruleFragment.setRules(mSchedulerRule);
            }
            DatabaseHelper dbHelper = DatabaseHelper.getInstance(RuleActivity.this);
            if (mNewRule) {
                dbHelper.addRule(mSchedulerRule);
            } else {
                dbHelper.updateRule(mSchedulerRule);
            }
            setResult(RESULT_OK);
            finish();
        }
    });
}

From source file:com.manjiler.mathhelper.activities.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());

    mContext = this.getBaseContext();

    // 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 ww w . ja  v a2s  .  c  om*/
    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: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.//w ww. j  av  a 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));
    }
}