Example usage for android.app ActionBar newTab

List of usage examples for android.app ActionBar newTab

Introduction

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

Prototype

@Deprecated
public abstract Tab newTab();

Source Link

Document

Create and return a new Tab .

Usage

From source file:com.christopher83.pkfmanager.PkfActivity.java

/**
 * Manages the activity creation//from w w  w . j  av a  2 s .  c om
 */
protected void onCreate(Bundle savedInstanceState) {
    // Invoke the base class method
    super.onCreate(savedInstanceState);

    // Set the content of the activity view
    setContentView(R.layout.activity_pkf);

    // If the kernel that doesn't support the Phantom Key Presses Filter module, then show an alert dialog
    if (!isPkfSupported(this))
        showPkfNotSupportedAlert();

    // 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 app
    _sectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(_sectionsPagerAdapter);

    // 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
    _viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        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 < _sectionsPagerAdapter.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(_sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.cachirulop.moneybox.activity.MainActivity.java

/**
 * Create the tabs with the sections of the application
 */// w  ww  .j a  v  a2 s.co  m
private void createTabs() {
    final ActionBar actionBar = getActionBar();

    // Create the adapter that will return a fragment for each of the
    // primary sections of the application.
    _sectionsPagerAdapter = new MoneyboxFragmentAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter.
    _viewPager = (ViewPager) findViewById(R.id.pager);
    _viewPager.setAdapter(_sectionsPagerAdapter);

    // 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.
    _viewPager.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 < _sectionsPagerAdapter.getCount(); i++) {
        actionBar
                .addTab(actionBar.newTab().setText(_sectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:net.forkk.autocron.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();
    assert actionBar != null;
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    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//  w  w w.  j  a v  a 2 s . com
        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));
    }
}

From source file:com.android.settings.HWSettings.java

private void setupAll(ActionBar bar) {
    final Tab tab = bar.newTab();
    tab.setText(R.string.hw_all);/*  w  ww.j a  v  a2s .co m*/
    tab.setTabListener(mTabListener);
    if (curTabIndex == TAB_INDEX_SYSTEM) {
        bar.addTab(tab, true);
    } else {
        bar.addTab(tab);
    }

}

From source file:com.example.emulator8051.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_home);

    // 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 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.*//* ww w .java2 s. c o  m*/
    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));
    }
}

From source file:com.android.settings.HWSettings.java

private void setupGeneral(ActionBar bar) {

    final Tab tab = bar.newTab();
    tab.setText(R.string.hw_general);/*w  ww  .  j a  v a  2 s  .c  o  m*/
    tab.setTabListener(mTabListener);
    if (curTabIndex == TAB_INDEX_NETWORKS) {
        bar.addTab(tab, true);
    } else {
        bar.addTab(tab);
    }
}

From source file:net.forkk.autocron.EditAutomationActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();/*from w w w. ja  v a  2 s . c  o  m*/
    assert intent != null;
    mAutomationPointer = (ComponentPointer) intent.getSerializableExtra(EXTRA_AUTOMATION_POINTER);

    mShowTriggerList = mAutomationPointer instanceof Event.Pointer;

    setContentView(R.layout.activity_edit_automation);

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    assert actionBar != null;
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the app.
    mPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mPagerAdapter);

    // 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 < mPagerAdapter.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(mPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}

From source file:com.microsoft.band.sdksample.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);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    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//w  ww .j  a v a  2  s  .  com
        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));
    }
}

From source file:org.messic.android.activities.BaseActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_base);

    // 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/*from   www  . ja va2  s .com*/
        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));
    }
}

From source file:capsrock.beta.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    timeSheet = new TimeSheet();
    PebbleData = new PebbleDictionary();
    //Set up to Receive messages from the pebble and handle them correctly
    PebbleKit.registerReceivedDataHandler(this, new PebbleKit.PebbleDataReceiver(PEBBLE_APP_UUID) {
        @Override//w ww .ja  va  2s .  c om
        public void receiveData(final Context context, final int transactionId, final PebbleDictionary data) {
            String mode = data.getString(1);
            //((TextView)findViewById(R.id.pebbleText)).setText(mode);
            if (mode.substring(9).equals("Break") || mode.substring(9).equals("Work")) {
                ((TimeEntryFragment) getSupportFragmentManager()
                        .findFragmentByTag("android:switcher:" + R.id.pager + ":0"))
                                .onTimeEntry(findViewById(R.id.StartButton), false);
            } else {
                ((TimeEntryFragment) getSupportFragmentManager()
                        .findFragmentByTag("android:switcher:" + R.id.pager + ":0"))
                                .onTimeEntry(findViewById(R.id.StopButton), false);
            }
            PebbleKit.sendAckToPebble(getApplicationContext(), transactionId);
        }
    });
    //Set up the timer thread
    thr = new Thread(new Runnable() {
        @Override
        public void run() {
            while (true) {
                try {
                    Thread.sleep(1000);
                    mHandler.post(new Runnable() {
                        @Override
                        public void run() {
                            Message mes = new Message();
                            if (strDate != null) {
                                long seconds = Calendar.getInstance().getTimeInMillis()
                                        - strDate.getTimeInMillis();
                                long minutes = seconds / 1000 / 60;
                                minutes %= 60;

                                long hours = seconds / 1000 / 60 / 60;
                                hours %= 24;

                                seconds /= 1000;
                                seconds %= 60;

                                String sec = hours + ":" + minutes + ":" + seconds;
                                mes.obj = sec;
                                mHandler.sendMessage(mes);
                            } else {
                                mes.obj = "00:00:00";
                                mHandler.sendMessage(mes);
                            }
                        }
                    });
                } catch (Exception e) {

                }
            }
        }
    });

    //Start Login Screen
    Intent intent = new Intent();
    intent.setClassName("capsrock.beta", "capsrock.beta.LoginActivity");
    //startActivity(intent);
    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.

    // 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++) {
        actionBar.addTab(
                actionBar.newTab().setText(mAppSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }
}