我正在使用具有ViewPager功能的android项目。这个相同的代码在其他日食中运行良好。但是在我的日食中,它显示出红色的下划线。
我在这里给了我的代码。
class SwipeTickerAdapter extends PagerAdapter {
LayoutInflater mInflater;
SwipeTickerAdapter(Context mContext) {
mInflater = LayoutInflater.from(mContext);
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
ViewGroup pageView = (ViewGroup) mInflater.inflate(
mLayoutsticker[position], container, false);
TextView b = (TextView) pageView.getChildAt(0);
try {
b.setText(annoncement_data.get(position * 2));
} catch (Exception e) {
e.printStackTrace();
}
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int val = mTickerpager.getCurrentItem();
System.out.println("Clicked current item is ---" + val
+ "&&&&&&&&&&" + annoncement_data.get(val * 2 + 1));
Resulttickettouch = annoncement_data.get(val * 2);
ArrayList<String> tickerSelectedValue = new ArrayList<String>();
tickerSelectedValue.add(annoncement_data.get(val * 2));
tickerSelectedValue.add(annoncement_data.get(val * 2 + 1));
startActivity(new Intent(mContext, HomeTickerPicker.class)
.putExtra("TickerValues", tickerSelectedValue));
ticket_ShowDialog();
// DemoPopupWindow dw = new DemoPopupWindow(v);
// dw.showLikeQuickAction(0, 30);
}
});
container.addView(pageView);
return pageView;
}
@Override
public int getCount() {
return legthticketview;
}
@Override
public boolean isViewFromObject(View view, Object obj) {
return view == obj;
}
}
上面的代码要求我在destroyItems和InstantiateItems中删除@override,如果我删除覆盖行,那么再次要求我添加未实现的方法。并在导入android.annotation.TargetApi;
中显示错误行帮我解决。