我编写了一个gettext资源编辑器,我需要在用户滑动ViewPager时实现跳过翻译令牌的功能。
我像这样填写View:
@Override
public Object instantiateItem(ViewGroup collection, int position) {
inflater = LayoutInflater.from(this.ctx);
View page = inflater.inflate(R.layout.slider, null);
((ViewPager) collection).addView(page, 0);
Message msg = this.messages.get(position);
this.original = (TextView) page.findViewById(R.id.textOriginal);
this.translated = (EditText) page.findViewById(R.id.editTranslated);
this.original.setText(msg.getMsgid());
this.translated.setText(msg.getMsgstr());
return page;
}
似乎getCurrentItem()和setCurrentItem()可能会对我有所帮助。但是如何处理边境案件(第一件或最后一件)?