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.example.jenil.parsedemo.GameShowActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
    setContentView(R.layout.activity_game_show_adapter);

    // 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./* ww  w. j  ava  2 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.pagerShow);
    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.dragamstudios.waarisdezon.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 ww w  .  j a  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.setOffscreenPageLimit(3);
    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:tn.codeit.darna.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // fragmentManager = getSupportFragmentManager();

    // 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();
    // ColorDrawable colorDrawable = new ColorDrawable(Color.parseColor("#2962FF"));
    //actionBar.setBackgroundDrawable(colorDrawable);
    // Specify that the Home/Up button should not be enabled, since there is no hierarchical
    // parent.//  w  ww.j a  v  a  2  s.  co 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.

    // 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("Accueil").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Map").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Filtrer").setTabListener(this));
    actionBar.addTab(actionBar.newTab().setText("Publier")

            .setTabListener(this));
    makeActionOverflowMenuShown();

}

From source file:com.mac.SafeWalk.WelcomeActivity.java

/**
 * Called when the activity is first created.
 *//*from w ww. ja  v  a2 s  .com*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.welcome_screen);
    // Create adapter
    collectionPagerAdapter = new CollectionPagerAdapter(getSupportFragmentManager());

    // Set up action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.hide();

    // 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
    // Attache the adapter and implement listener in order to respond when user swipes between sections.
    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(collectionPagerAdapter);
    viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // Select the corresponding tab when user swipes
            actionBar.setSelectedNavigationItem(position);
            ImageView dot1 = (ImageView) findViewById(R.id.sliding_dot1);
            ImageView dot2 = (ImageView) findViewById(R.id.sliding_dot2);
            switch (position) {
            case 0:
                animate(dot1);
                break;
            case 1:
                animate(dot2);
                break;
            case 2:
                break;
            }
        }
    });
    // For each of the sections, add tab to the action bar.
    for (int i = 0; i < collectionPagerAdapter.getCount(); i++) {
        // Create tabs
        actionBar.addTab(actionBar.newTab().setTabListener(this));
    }
    Settings.getSettings().setContext(this);
}

From source file:com.tesfayeabel.lolchat.ui.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_lolchat_main);
    viewPager = (ViewPager) findViewById(R.id.pager);
    final ActionBar actionBar = getActionBar();
    ArrayList<LOLChatFragment> fragments = new ArrayList<LOLChatFragment>();
    fragments.add(new MainFragment());
    fragments.add(new ConversationsFragment());
    fragments.add(new SummonerSearchFragment());
    viewPager.setOffscreenPageLimit(fragments.size() - 1);
    viewPager.setAdapter(new FragmentPagerAdapter(getFragmentManager(), fragments));
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    viewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        @Override/*from   w w  w. java2 s .  c  o  m*/
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            FragmentPagerAdapter adapter = (FragmentPagerAdapter) viewPager.getAdapter();
            if (getLolChat() != null)
                adapter.getRegisteredFragment(position).onChatConnected(getLolChat());
        }

        @Override
        public void onPageScrolled(int i, float f, int f1) {
        }

        @Override
        public void onPageScrollStateChanged(int i) {
        }
    });
    ActionBar.TabListener tl = new ActionBar.TabListener() {
        @Override
        public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
            viewPager.setCurrentItem(tab.getPosition());
        }

        @Override
        public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
        }

        @Override
        public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
        }
    };
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_friend).setTabListener(tl));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_recent).setTabListener(tl));
    actionBar.addTab(actionBar.newTab().setIcon(R.drawable.lolchat_search).setTabListener(tl));
}

From source file:com.cashout.paperless.fintech_paperless_cashout.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.// w  ww  .java  2 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));
    }

}

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

    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:com.example.swipedemo.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 . j  a  v a 2 s.  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.codebutler.farebot.activity.AdvancedCardInfoActivity.java

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

    findViewById(R.id.error_button).setOnClickListener(new View.OnClickListener() {
        @Override//w  w  w.j a v a2s .c  o m
        public void onClick(View v) {
            reportError();
        }
    });

    Serializer serializer = FareBotApplication.getInstance().getSerializer();
    mCard = Card.fromXml(serializer, getIntent().getStringExtra(AdvancedCardInfoActivity.EXTRA_CARD));

    ViewPager viewPager = (ViewPager) findViewById(R.id.pager);
    mTabsAdapter = new TabPagerAdapter(this, viewPager);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mCard.getCardType().toString() + " " + Utils.getHexString(mCard.getTagId(), "<error>"));

    if (mCard.getScannedAt().getTime() > 0) {
        String date = Utils.dateFormat(mCard.getScannedAt());
        String time = Utils.timeFormat(mCard.getScannedAt());
        actionBar.setSubtitle(Utils.localizeString(R.string.scanned_at_format, time, date));
    }

    if (getIntent().hasExtra(EXTRA_ERROR)) {
        mError = (Exception) getIntent().getSerializableExtra(EXTRA_ERROR);
        if (mError instanceof UnsupportedCardException) {
            findViewById(R.id.unknown_card).setVisibility(View.VISIBLE);
        } else if (mError instanceof UnauthorizedException) {
            findViewById(R.id.unauthorized_card).setVisibility(View.VISIBLE);
            findViewById(R.id.load_keys).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    startActivity(new Intent(AdvancedCardInfoActivity.this, AddKeyActivity.class));
                }
            });
        } else {
            findViewById(R.id.error).setVisibility(View.VISIBLE);
            ((TextView) findViewById(R.id.error_text)).setText(Utils.getErrorMessage(mError));
        }
    }

    CardHasManufacturingInfo infoAnnotation = mCard.getClass().getAnnotation(CardHasManufacturingInfo.class);
    if (infoAnnotation == null || infoAnnotation.value()) {
        mTabsAdapter.addTab(actionBar.newTab().setText(R.string.hw_detail), CardHWDetailFragment.class,
                getIntent().getExtras());
    }

    CardRawDataFragmentClass annotation = mCard.getClass().getAnnotation(CardRawDataFragmentClass.class);
    if (annotation != null) {
        Class rawDataFragmentClass = annotation.value();
        if (rawDataFragmentClass != null) {
            mTabsAdapter.addTab(actionBar.newTab().setText(R.string.data), rawDataFragmentClass,
                    getIntent().getExtras());
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        }
    }
}

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./*from ww  w . j  av  a2  s  .  c  om*/
    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));
    }
}