我正在使用ViewPagerExtensions。我想在Pager Adapter类的每个选项卡中开始一个新的活动。在PagerAdapter中开始新活动
眼下这是默认代码:
@Override
public Object instantiateItem(ViewGroup container, int position) {
RelativeLayout v = new RelativeLayout(mContext);
TextView t = new TextView(mContext);
t.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
t.setText(mData[position]);
t.setTextSize(30);
t.setGravity(Gravity.CENTER);
v.addView(t);
((ViewPager) container).addView(v, 0);
return v;
}
我想,因为它是为Android标签做什么事:
@Override
public Object instantiateItem(View container, int position) {
// Create an Intent to launch an Activity for the tab (to be reused)
intent = new Intent().setClass(this, NewActivity.class);
}
这引发错误:The method setClass(Context, Class<?>) in the type Intent is not applicable for the arguments (PagerAdapter, Class<NewActivity>)
。
感谢您的回复。那么计算器类将不得不以这种格式重新编码? – input 2012-07-21 21:30:52
看到我更新的答案 – 2012-07-22 03:01:09