An Android Library to help you create actionbar tabs like "Capitaine train" app by Cyril Mottier
Declare TabBarView and set a ViewPager
LayoutInflaterinflator =
(LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
Viewv = inflator.inflate(R.layout.custom_ab, null);
tabBarView = (TabBarView) v.findViewById(R.id.tab_bar);
getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getActionBar().setCustomView(v);
// Create the adapter that will return a fragment for each of the three// primary sections of the activity.mSectionsPagerAdapter = newSectionsPagerAdapter(getFragmentManager());
// Set up the ViewPager with the sections adapter.mViewPager = (ViewPager) findViewById(R.id.pager);
mViewPager.setAdapter(mSectionsPagerAdapter);
tabBarView.setViewPager(mViewPager);
Example using a simple pager adapter
publicclassSectionsPagerAdapterextendsFragmentPagerAdapterimplementsIconTabProvider{
privateint[] tab_icons={R.drawable.ic_tab1,
R.drawable.ic_tab2,
R.drawable.ic_tab3,
};
publicSectionsPagerAdapter(FragmentManagerfm) {
super(fm);
}
@OverridepublicFragmentgetItem(intposition) {
// getItem is called to instantiate the fragment for the given page.// Return a PlaceholderFragment (defined as a static inner class// below).returnPlaceholderFragment.newInstance(position + 1);
}
@OverridepublicintgetCount() {
// Show 3 total pages.returntab_icons.length;
}
@OverridepublicintgetPageIconResId(intposition) {
returntab_icons[position];
}
@OverridepublicCharSequencegetPageTitle(intposition) {
Localel = Locale.getDefault();
switch (position) {
case0:
returngetString(R.string.title_section1).toUpperCase(l);
case1:
returngetString(R.string.title_section2).toUpperCase(l);
case2:
returngetString(R.string.title_section3).toUpperCase(l);
}
returnnull;
}
}##Some ScreenShot
####License
Copyright 2014 Mirko Dimartino
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
####Developed by


