我在eclipse中有以下代码,我无法放置正确的布局和imageview,因为无法解析或不是字段
public ViewPagerAdapter(Context context, String[] gallery) {
this.context = context;
this.gallery = gallery;
}
@Override
public int getCount() {
return gallery.length;
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
@Override
public Object instantiateItem(ViewGroup container, int position) {
inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View itemView = inflater.inflate(R.layout.viewpager_item, container,
false);
// Locate the TextViews in viewpager_item.xml
ImageView imgflag = (ImageView) itemView.findViewById(R.id.image);
Picasso.with(context).load(gallery[position]).into(imgflag);
((ViewPager) container).addView(itemView);
return itemView;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
// Remove viewpager_item.xml from ViewPager
((ViewPager) container).removeView((View) object);
}
我尝试清理导入R的项目,并在我的项目/“Android工具”/“修复项目属性”中进行严格的点击。 我只有在创建适配器类
时才遇到此问题答案 0 :(得分:0)
尝试使用键组Ctr + Shift + o
让eclipse自动导入项目的必要内容。