我正在从pageradapter(到asyctask)传递它的位置
instanceiteItem(查看集合,int pos){.execute(pos);}
但是当我滑动到上一页时,它的位置错误,我怎样才能得到正确的上一个位置?
也许我可以使用 ViewPager getCurrentItem() 来检索当前页面的索引,但是如何将它与我的代码一起使用?
public class QuestionPagerAdapter extends PagerAdapter{
public QuestionPagerAdapter(){
super();
}
@Override
public int getCount() {
int qcount = QuestionPagerAdapter.q.getQuestionCount();
return qcount;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == ((View) object);
}
@Override
public Object instantiateItem(View collection, int pos) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View page = inflater.inflate(R.layout.page_quiz, null);
TextView tv = (TextView)page.findViewById(R.id.questionText);
QuizFetchTask fft = new QuizFetchTask(tv);
fft.execute(pos);
((ViewPager) collection).addView(page, 0);
return page;
}
@Override
public void destroyItem(View collection, int position, Object view) {
//Util.Log("destroying" + position);
((ViewPager) collection).removeView((View) view);
}
}