Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public class TabsPagerAdapter extends PagerAdapter {
String tabs[]={"Test 1","Test 2","Test 3","Test 4","Test 5","Test 6","Test 7","Test 8"};
Activity activity;
public TabsPagerAdapter(Activity activity){
public int getCount() {
return tabs.length;
public boolean isViewFromObject(View view, Object o) {
return o == view;
public CharSequence getPageTitle(int position) {
return tabs[position];
public Object instantiateItem(ViewGroup container, int position) {
// Inflate a new layout from our resources
View view=null;
view = activity.getLayoutInflater().inflate(R.layout.pager_item,container, false);
view = activity.getLayoutInflater().inflate(R.layout.pager_item_2,container, false);
// Add the newly created View to the ViewPager
// Retrieve a TextView from the inflated View, and update it's text
TextView title = (TextView) view.findViewById(;
// Return the View
return view;
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.