package com.example.mountaintravel.adapter;

import java.util.ArrayList;
import java.util.List;



import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

public class MyPagerAdapter extends PagerAdapter {
	
	private List<View> lists;
	private List<String> titles;

	public MyPagerAdapter() {
		super();
		lists = new ArrayList<View>();
		titles = new ArrayList<String>();
	}

	public void addView(View v) {
		lists.add(v);
	}

	public void delView(View v) {
		lists.remove(v);
	}

	public void addTitle(String t) {
		titles.add(t);
	}

	@Override
	public void setPrimaryItem(ViewGroup container, int position, Object object) {
		// TODO Auto-generated method stub
	}

	public void delTitle(String t) {
		titles.remove(t);
	}

	@Override
	public CharSequence getPageTitle(int position) {
		// TODO Auto-generated method stub
		return titles.get(position);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return lists.size();
	}

	@Override
	public void destroyItem(ViewGroup container, int position, Object object) {
		// TODO Auto-generated method stub
		container.removeView(lists.get(position));
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		// TODO Auto-generated method stub
		View v = lists.get(position);
		container.addView(v);
		return v;
	}

	@Override
	public boolean isViewFromObject(View arg0, Object arg1) {
		// TODO Auto-generated method stub
		return arg0 == arg1;
	}

}
