public class myPagerAdapter extends PagerAdapter{
private LayoutInflater mInflater;
public myPagerAdapter(Context context) {
super();
mInflater = LayoutInflater.from(context);
}
// PagerAdapter에서 관리할 View 개수를 반환합니다.
public int getCount() {
return 3;
}
// ViewPager에서 사용할 View를 생성하고 등록해줍니다.
public Object instantiateItem(View pager, int position){
View v = null;
v = mInflater.inflate(R.layout.main, null);
Toast.makeText(mContext, " position = "+position, 1).show();
((ViewPager)pager).addView(v, 0);
return v;
}
// View를 삭제합니다.
public void destroyItem(View pager, int position, Object view) {
((ViewPager)pager).removeView((View)view);
}
// instantiateItem에서 생성한 객체를 이용할 것인지 여부를 반환합니다.
public boolean isViewFromObject(View v, Object obj) {
return v == obj;
}
}
맨처음 로드할때 position이 0하고 1이 표시됩니다
좌우로 스클로을 하면 position이 어떨때는 표시가 되고 어떨때는 표시가 안됩니다
position이 제대로 표시가 안되니까 배열을 이용할려고 해도 못하고 잇습니다
좌우로 스클롤하면 올바르게 position이 표시가 되도록 하려면 어떻게 하면 되나요?