@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); }
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); }
private void setupFavorites() { final Tab tab = getActionBar().newTab(); tab.setContentDescription(R.string.contactsFavoritesLabel); tab.setIcon(R.drawable.ic_tab_all); tab.setTabListener(mTabListener); getActionBar().addTab(tab); }
private void setupCallLog() { final Tab tab = getActionBar().newTab(); tab.setContentDescription(R.string.recentCallsIconLabel); tab.setIcon(R.drawable.ic_tab_recent); tab.setTabListener(mTabListener); getActionBar().addTab(tab); }
private void setupDialer() { final Tab tab = getActionBar().newTab(); tab.setContentDescription(R.string.dialerIconLabel); tab.setTabListener(mTabListener); tab.setIcon(R.drawable.ic_tab_dialer); getActionBar().addTab(tab); }
public void addTab(Tab tab, Class<?> _clss, Bundle _args) { TabInfo info = new TabInfo(_clss, _args); tab.setTag(info); tab.setTabListener(this); mTabInfos.add(info); mActionBar.addTab(tab); notifyDataSetChanged(); }
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) { try { Ctxt = this; super.onCreate(savedInstanceState); setContentView(R.layout.activity_measurements_entry); // 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 action bar. final ActionBar actionBar = getActionBar(); actionBar.setDisplayShowTitleEnabled(false); actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // 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 // listener for when this tab is selected. Tab tab = actionBar.newTab(); tab.setText(mSectionsPagerAdapter.getPageTitle(i)); // tab.setIcon(icon) tab.setTabListener(this); actionBar.addTab(tab); } } catch (Exception e) { e.printStackTrace(); } }
@SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { // Initialize Context and SharedPreferences. mContext = this; mApp = (Common) mContext.getApplicationContext(); // Retrieve the name/icon of the library from the arguments. libraryName = getIntent().getExtras().getString("LIBRARY_NAME"); libraryIconName = getIntent().getExtras().getString("LIBRARY_ICON"); if (getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET") != null) { songDBIdsList = (HashSet<String>) getIntent().getExtras().getSerializable("SONG_IDS_HASH_SET"); } // Set the UI theme. if (mApp.getCurrentTheme() == Common.DARK_THEME) { setTheme(R.style.AppTheme); } else { setTheme(R.style.AppThemeLight); } super.onCreate(savedInstanceState); // Initialize the database helper. dbHelper = new DBAccessHelper(mContext.getApplicationContext()); // Create a set of options to optimize the bitmap memory usage. final BitmapFactory.Options options = new BitmapFactory.Options(); options.inJustDecodeBounds = true; options.inJustDecodeBounds = false; options.inPurgeable = true; // Display Image Options. int defaultArt = UIElementsHelper.getIcon(mContext, "default_album_art_padded"); displayImageOptions = new DisplayImageOptions.Builder() .showImageForEmptyUri(R.drawable.default_album_art) .showImageOnFail(R.drawable.default_album_art) .showStubImage(R.drawable.transparent_drawable) .cacheInMemory(false) .cacheOnDisc(true) .decodingOptions(options) .imageScaleType(ImageScaleType.EXACTLY) .bitmapConfig(Bitmap.Config.RGB_565) .displayer(new FadeInBitmapDisplayer(400)) .delayBeforeLoading(100) .build(); // Attach tabs to the ActionBar. ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); // Add the artists tab. String artistsLabel = getResources().getString(R.string.artists); Tab tab = actionBar.newTab(); tab.setText(artistsLabel); TabListener<ArtistsPickerFragment> artistsTabListener = new TabListener<ArtistsPickerFragment>(this, artistsLabel, ArtistsPickerFragment.class); tab.setTabListener(artistsTabListener); actionBar.addTab(tab); // Add the albums tab. String albumsLabel = getResources().getString(R.string.albums); tab = actionBar.newTab(); tab.setText(albumsLabel); TabListener<AlbumsPickerFragment> albumsTabListener = new TabListener<AlbumsPickerFragment>(this, albumsLabel, AlbumsPickerFragment.class); tab.setTabListener(albumsTabListener); actionBar.addTab(tab); // Add the songs tab. String songsLabel = getResources().getString(R.string.songs); tab = actionBar.newTab(); tab.setText(songsLabel); TabListener<SongsPickerFragment> songsTabListener = new TabListener<SongsPickerFragment>(this, songsLabel, SongsPickerFragment.class); tab.setTabListener(songsTabListener); actionBar.addTab(tab); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { getWindow().setBackgroundDrawable(UIElementsHelper.getGeneralActionBarBackground(mContext)); int topPadding = Common.getStatusBarHeight(mContext); View activityView = (View) findViewById(android.R.id.content); // Calculate ActionBar height TypedValue tv = new TypedValue(); int actionBarHeight = 0; if (getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics()); } if (activityView != null) { activityView.setPadding(0, topPadding + actionBarHeight, 0, 0); } } }