我在 Android 中使用了一个相当简单的自定义寻呼机适配器,我想跟踪编辑文本字段的内容,以便每张新幻灯片在输入时都保留相同的文本。有人对此有任何见解吗?我猜我需要为文本更改设置一个侦听器,但我不确定该放在哪里。这是我的适配器:
private class CustomPagerAdapter extends PagerAdapter {
public int getCount() {
return 3;
}
public Object instantiateItem(ViewGroup collection, int position) {
LayoutInflater inflater = (LayoutInflater) collection.getContext()
.getSystemService(LAYOUT_INFLATER_SERVICE);
View view;
switch(position) {
case 0:
view = inflater.inflate(R.layout.slide0, null, false);
break;
case 1:
view = inflater.inflate(R.layout.slide1, null, false);
break;
case 2:
view = inflater.inflate(R.layout.slide2, null, false);
break;
default:
view = inflater.inflate(R.layout.slide0, null, false);
}
collection.addView(view,0);
return view;
}
@Override
public void destroyItem(ViewGroup arg0, int arg1, Object arg2) {
arg0.removeView((View) arg2);
}
@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 == arg1;
}
@Override
public Parcelable saveState() {
return null;
}
@Override
public void setPrimaryItem(ViewGroup container, int position, Object object) {
super.setPrimaryItem(container, position, object);
mCurrentSlide = (View) object;
}
}