@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_contact_mail); // needed? // implement action bar ActionBar aBar = getActionBar(); aBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); aBar.setDisplayHomeAsUpEnabled(true); // friend tab String lab1 = getResources().getString(R.string.friends); // what do i id? Tab tab = aBar.newTab(); tab.setText(lab1); TabListener<friendFrag> friFrag = new TabListener<friendFrag>(this, lab1, friendFrag.class); tab.setTabListener(friFrag); aBar.addTab(tab); // mail tab String lab2 = getResources().getString(R.string.mail); tab = aBar.newTab(); tab.setText(lab2); TabListener<mailFrag> mFrag = new TabListener<mailFrag>(this, lab2, mailFrag.class); tab.setTabListener(mFrag); aBar.addTab(tab); }
private void intiActionTab() { actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(false); actionBar.setDisplayShowTitleEnabled(false); actionBar.setDisplayShowHomeEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); tab_top = actionBar.newTab().setText("头条"); tab_cyclopedia = actionBar.newTab().setText("百科"); tab_message = actionBar.newTab().setText("资讯"); tab_manage = actionBar.newTab().setText("经营"); tab_data = actionBar.newTab().setText("数据"); tab_top.setTabListener(this); tab_cyclopedia.setTabListener(this); tab_message.setTabListener(this); tab_manage.setTabListener(this); tab_data.setTabListener(this); actionBar.addTab(tab_top); actionBar.addTab(tab_cyclopedia); actionBar.addTab(tab_message); actionBar.addTab(tab_manage); actionBar.addTab(tab_data); }
public void setUpGUI() { ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); String tab1 = getResources().getString(R.string.label1); String tab2 = getResources().getString(R.string.label2); String tab3 = getResources().getString(R.string.label3); Tab tab = actionBar .newTab() .setText(tab1) .setTabListener(new TabListener<CurrentFragment>(this, tab1, CurrentFragment.class)); actionBar.addTab(tab, 0, curTab == 0); tab = actionBar .newTab() .setText(tab2) .setTabListener(new TabListener<NearbyFragment>(this, tab2, NearbyFragment.class)); actionBar.addTab(tab, 1, curTab == 1); tab = actionBar .newTab() .setText(tab3) .setTabListener(new TabListener<AllFragment>(this, tab3, AllFragment.class)); actionBar.addTab(tab, 2, curTab == 2); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_profile); bargain_user = (User) getIntent().getSerializableExtra("USER_PROFILE"); user_deal_data = FeedActivity.user_deal_data; user_like_data = FeedActivity.user_like_data; final ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() { public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); // naming the tabs of the ActionBar actionBar.addTab(actionBar.newTab().setText(R.string.title_profile).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_liked_deals).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.my_deals).setTabListener(this)); mViewPager.setAdapter(mAppSectionsPagerAdapter); }
private void initializeBrowseTabs() { ActionBar actionBar = getActivity().getActionBar(); TabListener listener = getTabListener(); // Initialize Featured Tab position=1 Tab actionBarTab = actionBar.newTab().setTabListener(listener); actionBarTab.setIcon( new IconDrawable(getActivity(), IconValue.fa_film) .colorRes(R.color.actionbar_tab_text) .actionBarSize()); actionBar.addTab(actionBarTab); // Initialize Varieties Tab position=2 actionBarTab = actionBar.newTab().setTabListener(listener); actionBarTab.setIcon( new IconDrawable(getActivity(), IconValue.fa_th_large) .colorRes(R.color.actionbar_tab_text) .actionBarSize()); actionBar.addTab(actionBarTab); // Initialize All Tab position=3 actionBarTab = actionBar.newTab().setTabListener(listener); actionBarTab.setIcon( new IconDrawable(getActivity(), IconValue.fa_archive) .colorRes(R.color.actionbar_tab_text) .actionBarSize()); actionBar.addTab(actionBarTab); }
private void InitActionBar() { MyTabListener mtabListener = new MyTabListener(); mActionBar = getActionBar(); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mActionBar.addTab(mActionBar.newTab().setText("Topic").setTabListener(mtabListener)); mActionBar.addTab(mActionBar.newTab().setText("Question").setTabListener(mtabListener)); mActionBar.addTab(mActionBar.newTab().setText("Sample").setTabListener(mtabListener)); mActionBar.setDisplayHomeAsUpEnabled(true); mActionBar.setTitle("Search"); }
private void addTabs() { ActionBar.Tab addNewExpenseTab = actionBar.newTab(); addNewExpenseTab.setTabListener(this); addNewExpenseTab.setText("Add New"); actionBar.addTab(addNewExpenseTab); ActionBar.Tab todayTab = actionBar.newTab(); todayTab.setTabListener(this); todayTab.setText("Today"); actionBar.addTab(todayTab); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_fragment_tabs); // Add 3 tabs which will switch fragments ActionBar ab = getActionBar(); ab.addTab(ab.newTab().setText("Tab 1").setTabListener(this)); ab.addTab(ab.newTab().setText("Tab 2").setTabListener(this)); ab.addTab(ab.newTab().setText("Tab 3").setTabListener(this)); ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); }
public void attachTabs(ActionBar bar) { TabListener tl = new TabListener(this, this); Tab tab1 = bar.newTab(); tab1.setText("Tab1"); tab1.setTabListener(tl); bar.addTab(tab1); Tab tab2 = bar.newTab(); tab2.setText("Tab2"); tab2.setTabListener(tl); bar.addTab(tab2); }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // set up actionbar to show tabs final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // add tabs actionBar.addTab(actionBar.newTab().setText(R.string.make_tag).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.my_tags).setTabListener(this)); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar to show tabs. final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // For each of the sections in the app, add a tab to the action bar. actionBar.addTab(actionBar.newTab().setText(R.string.title_section1).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section2).setTabListener(this)); actionBar.addTab(actionBar.newTab().setText(R.string.title_section3).setTabListener(this)); }
private void buildActionBarAndViewPagerTitles() { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setTitle(getString(R.string.detail)); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab( actionBar.newTab().setText(getString(R.string.weibo)).setTabListener(tabListener)); actionBar.addTab( actionBar.newTab().setText(getString(R.string.comments)).setTabListener(tabListener)); actionBar.addTab( actionBar.newTab().setText(getString(R.string.repost)).setTabListener(tabListener)); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getActivity().getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); if (actionBar.getTabCount() != 3) { ActionBar.TabListener tabListener = new ActionBar.TabListener() { @Override public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // setCurrentItem(tab.getPosition()); int position = tab.getPosition(); if (position == 0) { fragmentTransaction.replace(R.id.frame_layout, dailyFrag); } else if (position == 1) { fragmentTransaction.replace(R.id.frame_layout, weeklyFrag); } else if (position == 2) { fragmentTransaction.replace(R.id.frame_layout, monthlyFrag); } } @Override public void onTabUnselected( ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // No special actions. } @Override public void onTabReselected( ActionBar.Tab tab, FragmentTransaction fragmentTransaction) { // User selected the already selected tab. In this case do nothing. } }; ActionBar.Tab tabDaily = actionBar.newTab().setText(R.string.history_daily).setTabListener(tabListener); ActionBar.Tab tabWeekly = actionBar.newTab().setText(R.string.history_weekly).setTabListener(tabListener); ActionBar.Tab tabMonthly = actionBar.newTab().setText(R.string.history_monthly).setTabListener(tabListener); actionBar.removeAllTabs(); actionBar.addTab(tabDaily); actionBar.addTab(tabWeekly); actionBar.addTab(tabMonthly); } }
private void initTabs() { listingListener = new TabListener<ListingListFragment>(this, "listinglist", ListingListFragment.class); ActionBar.Tab tab = actionBar.newTab().setText("Listings").setTabListener(listingListener); actionBar.addTab(tab); tab = actionBar .newTab() .setText("Requests") .setTabListener( new TabListener<RequestListFragment>( this, "requestlist", RequestListFragment.class)); actionBar.addTab(tab); myListingFrag = (ListingListFragment) listingListener.getFragment(); myListingFrag.setClient(myClient); }
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_attention); mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager()); final ActionBar actionBar = getActionBar(); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); mViewPager = (ViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mAppSectionsPagerAdapter); mViewPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { actionBar.setSelectedNavigationItem(position); } }); for (int i = 0; i < mAppSectionsPagerAdapter.getCount(); i++) { actionBar.addTab( actionBar .newTab() .setText(mAppSectionsPagerAdapter.getPageTitle(i)) .setTabListener(this)); } }
public void onCreate(Bundle savedBundle) { super.onCreate(savedBundle); setContentView(R.layout.dalevents); getActionBar().setIcon(R.drawable.ic_launcher); viewPager = (ViewPager) findViewById(R.id.adminpager); actionBar = getActionBar(); mAdapter = new ClientTabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } viewPager.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page // make respected tab selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int arg0) {} }); }
@Override protected void onCreate(Bundle savedInstanceState) { SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this); String Language = preferences.getString("Lang", "no_find"); Locale mylocale = new Locale(Language); if (Language == "no_find") mylocale = Resources.getSystem().getConfiguration().locale; Resources res1 = getResources(); Configuration conf = res1.getConfiguration(); conf.locale = mylocale; DisplayMetrics dm = res1.getDisplayMetrics(); res1.updateConfiguration(conf, dm); Locale.setDefault(mylocale); 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 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 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)); } // initializes the control object which serves as the interface between the gui and // the usb communication control = (Control) getLastCustomNonConfigurationInstance(); if (control == null) { Resources res = getResources(); String[] commands = res.getStringArray(R.array.command_select_options); control = new Control(); Control.initialize(commands); } // launchAboutActivity(); }
public void onAddTab(View v) { final ActionBar bar = getActionBar(); final int tabCount = bar.getTabCount(); final String text = "Tab " + tabCount; bar.addTab( bar.newTab().setText(text).setTabListener(new TabListener(new TabContentFragment(text)))); }
/** Adds tabs below the action bar. */ private void addTabs() { viewPager = (ViewPager) findViewById(R.id.pager_main); actionBar = getActionBar(); mAdapter = new TabsPagerAdapter(getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(false); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // temp fix, to make sure that PATHAlerts isn't refreshing all the time viewPager.setOffscreenPageLimit(4); // Adding Tabs for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } viewPager.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { // on changing the page // make respected tab selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int arg0) {} }); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); viewPager = (ViewPager) getActivity().findViewById(R.id.pager); actionBar = getActivity().getActionBar(); mAdapter = new Course1Adapter(getActivity().getSupportFragmentManager()); viewPager.setAdapter(mAdapter); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Add the tabs here for (String tab_name : tabs) { actionBar.addTab(actionBar.newTab().setText(tab_name).setTabListener(this)); } viewPager.setOnPageChangeListener( new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { // on Page change, that particular page should be selected actionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int arg0, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int position) {} }); }
@Override protected void onCreate(Bundle savedInstanceState) { Log.i(TAG, "setting selected id from intent"); setSelectedItemIDFromIntent(); ActiveUser activeUser = ((GiveOrTakeApplication) getApplication()).getActiveUser(); if (activeUser == null || activeUser.getUserID() == null) { Intent logoutIntent = new Intent(this, LoginActivity.class); logoutIntent.putExtra(LoginFragment.EXTRA_LOGIN_ACTION, LoginFragment.LOGOUT); logoutIntent.putExtra(MainActivity.EXTRA_ITEM_ID, getSelectedItemID()); startActivity(logoutIntent); finish(); } 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 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 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)) .setIcon(mSectionsPagerAdapter.getPageIcon(i)) .setTabListener(this)); } actionBar.selectTab(actionBar.getTabAt(DEFAULT_SELECTED_TAB)); Long itemID = getSelectedItemID(); if (itemID != null) { actionBar.selectTab(actionBar.getTabAt(FREE_ITEMS_TAB)); } }
@Override protected void onCreate(Bundle savedInstanceState) { this.context = getApplicationContext(); super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Set up the action bar. // setup action bar for tabs final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayShowTitleEnabled(false); // 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); } }); actionBar.addTab( actionBar .newTab() .setText(mSectionsPagerAdapter.getPageTitle(0)) .setTabListener(new TabListener<Feed>(this, "", Feed.class))); actionBar.addTab( actionBar .newTab() .setText(mSectionsPagerAdapter.getPageTitle(1)) .setTabListener(new TabListener<Circles>(this, "", Circles.class))); actionBar.addTab( actionBar .newTab() .setText(mSectionsPagerAdapter.getPageTitle(2)) .setTabListener(new TabListener<Profile>(this, "", Profile.class))); }
public void Add(String _title, View _panel, View _customTabView) { ActionBar.Tab tab = CreateTab(_title, _panel); _customTabView.setVisibility(View.VISIBLE); tab.setCustomView(_customTabView); // This overrides values set by setText(CharSequence) and // setIcon(Drawable). ActionBar actionBar = this.controls.activity.getActionBar(); actionBar.addTab(tab, false); }
public void addTab(ActionBar.Tab tab, Class<?> clss, Bundle args) { TabInfo info = new TabInfo(clss, args); tab.setTag(info); tab.setTabListener(this); mTabs.add(info); mActionBar.addTab(tab); notifyDataSetChanged(); }
@Override protected void handleResult(String jsonStr) { if (this.actioncode == 17) { try { JSONObject json = new JSONObject(jsonStr); if (json != null) { JSONArray jsonarray = json.getJSONArray("housebuilddata"); for (int i = 0; i < jsonarray.length(); i++) { JSONObject rec = jsonarray.getJSONObject(i); JSONArray jarrayname = rec.getJSONArray("basebuildingflag"); for (int j = 0; j < jarrayname.length(); j++) { aryBasicBuildingFlag[j] = jarrayname.getString(j).toString(); } JSONArray jarrayname2 = rec.getJSONArray("militarybuildingflag"); for (int y = 0; y < jarrayname2.length(); y++) { aryMilitaryBuildingFlag[y] = jarrayname2.getString(y).toString(); } } } } catch (JSONException e) { for (int i = 0; i < 4; i++) { aryBasicBuildingFlag[i] = "0"; } for (int i = 0; i < 8; i++) { aryMilitaryBuildingFlag[i] = "0"; } } release(); final ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE); actionBar.addTab( actionBar .newTab() .setText("基本建筑") .setTabListener(new TabListener(new BaseInfoShowTabContentFragment()))); actionBar.addTab( actionBar .newTab() .setText("军事建筑") .setTabListener(new TabListener(new MilitaryInfoShowTabContentFragment()))); } }
public void workwithTabbedActionBar() { ActionBar bar = this.getActionBar(); bar.setTitle(tag); bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); TabListener tl = new TabListener(this, this); Tab tab1 = bar.newTab(); tab1.setText("Tab1"); tab1.setTabListener(tl); bar.addTab(tab1); Tab tab2 = bar.newTab(); tab2.setText("Tab2"); tab2.setTabListener(tl); bar.addTab(tab2); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // add necessary intent values to be matched. mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION); mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_PEERS_CHANGED_ACTION); mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_CONNECTION_CHANGED_ACTION); mIntentFilter.addAction(WifiP2pManager.WIFI_P2P_THIS_DEVICE_CHANGED_ACTION); // Initialise LocalServiceReciever mLIntentFilter.addAction(SocketService.UPDATE_LIST); mLReciever = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { updateMap(); } }; // Initialise mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE); mChannel = mManager.initialize(this, getMainLooper(), null); // Initialise mViewPager = (ViewPager) findViewById(R.id.pager); mActionBar = getActionBar(); mAdaptor = new TabsPagerAdaptor(getFragmentManager()); // Set the Tabs Pager mViewPager.setAdapter(mAdaptor); mActionBar.setHomeButtonEnabled(false); mActionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Add tabs for (int i = 0; i < mAdaptor.getCount(); i++) { mActionBar.addTab(mActionBar.newTab().setText(mAdaptor.getPageTitle(i)).setTabListener(this)); } // Bind to SocketService bindSocketService(); // ensure that tabs work mViewPager.setOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageSelected(int position) { mActionBar.setSelectedNavigationItem(position); } @Override public void onPageScrolled(int position, float arg1, int arg2) {} @Override public void onPageScrollStateChanged(int index) {} }); }
// This method adds a tab for use in tabbed navigation mode public void Add(String _title, View _panel, String _iconIdentifier) { ActionBar.Tab tab = CreateTab(_title, _panel); if (!_iconIdentifier.equals("")) { tab.setIcon( GetDrawableResourceById(GetDrawableResourceId(_iconIdentifier))); // _iconIdentifier } ActionBar actionBar = this.controls.activity.getActionBar(); actionBar.addTab(tab, false); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); for (int i = 1; i <= 3; i++) { ActionBar.Tab tab = actionBar.newTab().setText("Tab#" + i).setTabListener(this); actionBar.addTab(tab); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.fourth_task_android); applicationObject = (ApplicationObject) getApplication(); fragmentManager = getFragmentManager(); fragmentManager.addOnBackStackChangedListener(new SmartBackStackListener()); localBroadcastManager = LocalBroadcastManager.getInstance(FourthTaskAndroid.this); broadcastReceiver = new WeatherChangesBroadcastReceiver(); // Specify that we will be displaying tabs in the action bar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.addTab( actionBar.newTab().setText(getString(R.string.label_list)).setTabListener(this)); actionBar.addTab( actionBar.newTab().setText(getString(R.string.label_map)).setTabListener(this)); }