List of usage examples for android.app ActionBar newTab
@Deprecated public abstract Tab newTab();
From source file:com.mstoyanov.music_lessons.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w . j a v a 2 s . c o m final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // if returning from an activity: if (getIntent().getStringExtra("WEEKDAY") != null) { weekday = getIntent().getStringExtra("WEEKDAY"); } if (getIntent().getIntExtra("SELECTED_TAB", 0) != 0) { selectedTab = getIntent().getIntExtra("SELECTED_TAB", 0); } mViewPager = (ViewPager) findViewById(R.id.pager); mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager()); mViewPager.setAdapter(mSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (position == 6) { section = position; // "Students" tab actionBar.setSelectedNavigationItem(1); } else if (position == 7) { section = position; // "Add Student" tab actionBar.setSelectedNavigationItem(2); } else { section = position; // a schedule tab actionBar.setSelectedNavigationItem(0); } } }); // Add tabs to the action bar: for (int i = 0; i < 3; i++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } actionBar.selectTab(actionBar.getTabAt(selectedTab)); }
From source file:com.joncairo.android.todo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set up the main activity view to be populated with fragments. setContentView(R.layout.activity_main); // Set up the action bar for tabs final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Create the adapter to manage tab switching 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 v a 2 s .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)); } // Wire up the to do text entry field mNewToDoName = (EditText) findViewById(R.id.todo_text); mNewToDoName.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { DataLoader dataLoader = new DataLoader(getBaseContext(), mDataFileName); dataLoader.setTextInputData(s.toString()); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { } }); // Wire up the to do enter button Button mDoIt = (Button) findViewById(R.id.enter_button); mDoIt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ArrayList<Todo> mToDoToBeAdded = new ArrayList<Todo>(); String newToDoText = setInputText(); // Create a new todo instance Todo newTodo = new Todo(newToDoText); mToDoToBeAdded.add(newTodo); // delete the text //mNewToDoName.setText(""); // append it to the todolist array mtoDoFragment.addItemsToList(mToDoToBeAdded, ""); } }); }
From source file:de.da_sense.moses.client.WelcomeActivity.java
@Override public void onCreate(Bundle savedInstanceState) { Log.d(LOG_TAG, "onCreate() called"); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); thisInstance = this; mAppSectionsPagerAdapter = new WelcomeActivityPagerAdapter(getSupportFragmentManager(), this); // get ActionBar and set NavigationMode final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override/*ww w . j a va2s. co m*/ public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); 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)); } // Moses got called to view a UserStudy boolean isShowUserStudyCall = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID) != null; if (isShowUserStudyCall) { onLoginCompleteShowUserStudy = getIntent() .getStringExtra(ViewUserStudyActivity.EXTRA_USER_STUDY_APK_ID); } if (!isLoginInformationComplete(this) && !waitingForResult) { // Here, the activity is called to display the login screen, and, // when filled in, redirect the user to the user study that was // meant to be displayed originally waitingForResult = true; // set flag that on login credentials arrival show a user study // set the deviceID in the SharedPreferences before attempting to // login String theDeviceID = Secure.getString(getContentResolver(), Secure.ANDROID_ID); PreferenceManager.getDefaultSharedPreferences(this).edit() .putString(MosesPreferences.PREF_DEVICEID, theDeviceID).commit(); Intent loginDialog = new Intent(WelcomeActivity.this, LoginActivity.class); startActivityForResult(loginDialog, 1); } if (HistoryExternalApplicationsManager.getInstance() == null) { HistoryExternalApplicationsManager.init(this); } if (InstalledExternalApplicationsManager.getInstance() == null) { InstalledExternalApplicationsManager.init(this); } if (UserstudyNotificationManager.getInstance() == null) { UserstudyNotificationManager.init(this); } // initialize the UI elements initControls(savedInstanceState); }
From source file:com.mitchtodd.myweatherapp.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 single instance of weather model to be used by activity and tab fragments. mWeatherModel = new WeatherModel(this); mWeatherModel.addOnGetWeatherStartedListener(onGetWeatherStartedListener); mWeatherModel.addOnGetWeatherFinishedListener(onGetWeatherFinishedListener); mWeatherModel.startWeatherUpdates(); setLastUpdatedText(true);/*from w w w . j a v a2s .c om*/ findViewById(R.id.refreshButton).setOnClickListener(onRefreshButtonClickListener); // create the adapter that will return a fragment for each of the 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); // set up swipe listener 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++) { actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:com.glanznig.beepme.view.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main);//from w w w. j av a2s . co m audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); pagerAdapter = new MainSectionsPagerAdapter(getSupportFragmentManager(), this); final ActionBar actionBar = getActionBar(); final BeeperApp app = (BeeperApp) getApplication(); if (app.getPreferences().isTestMode()) { actionBar.setSubtitle(getString(R.string.pref_title_test_mode)); } // displaying tabs in the action bar actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); pager = (ViewPager) findViewById(R.id.main_tab_pager); pager.setAdapter(pagerAdapter); // set gap between pages pager.setPageMargin((int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 4, this.getResources().getDisplayMetrics())); pager.setPageMarginDrawable(R.drawable.swipe_filler); // listening for page changes pager.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 < pagerAdapter.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(pagerAdapter.getPageTitle(i)).setTabListener(this)); } }
From source file:net.networksaremadeofstring.rhybudd.FirstRunSettings.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_first_run_settings); // Set up the action bar. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setTitle(getString(R.string.FirstRunTitle)); actionBar.setSubtitle(getString(R.string.FirstRunSubtitle)); // 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 w w . j av a 2 s .co 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)); } }
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.// ww w. ja v a 2 s .com 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.android.cts.uiautomator.Test4DetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { View rootView = inflater.inflate(R.layout.test4_detail_fragment, container, false); // Set up the action bar. final ActionBar actionBar = getActivity().getActionBar(); if (actionBar.getTabCount() > 0) { return rootView; }//from w w w. j av a2 s . c o m 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(getActivity().getSupportFragmentManager()); // Set up the ViewPager with the sections adapter. mViewPager = (ViewPager) rootView.findViewById(R.id.test_4_detail_container); 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 listener for when this tab is // selected. actionBar .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this)); } return rootView; }
From source file:com.witmob.nocollapsetabs.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(); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayShowTitleEnabled(false); // Specify that the Home/Up button should not be enabled, since there is no hierarchical // parent./* w w w .j ava2 s . c o m*/ actionBar.setHomeButtonEnabled(false); // Specify that we will be displaying tabs in the action bar. // 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)); } actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }
From source file:com.android.projectesang.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 av a 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)); } }