The method isViewFromObject(View, Object) of type new PagerAdapter(){} must override or implement a supertype method
网上说的方法: 一、
因为你的Compiler 是jdk1.5,只要把它改为 1.6
方法:
项目右键->build path->configure build path->java Compiler(左边那排中) ->在右边的Compiler compliance level 修改版本为6.0
试过了没有作用。
import java.awt.Window;
import java.util.ArrayList;
import java.util.List;
import javax.swing.text.View;
import com.csst.videotalk.R;
import android.app.Activity;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.ViewGroup;
public class ViewPaper_activity extends Activity
{
ViewPager mViewPager;
private int[] mImgIds = new int[] { /*R.drawable.guide_image1,
R.drawable.guide_image2, R.drawable.guide_image3 */};
private List mImageViews = new ArrayList();
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
//requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.view_paper);
initData();
mViewPager = (ViewPager) findViewById(R.id.id_viewpager);
mViewPager.setAdapter(new PagerAdapter()
{
@Override
public Object instantiateItem(ViewGroup container, int position)
{
container.addView(mImageViews.get(position));
return mImageViews.get(position);
}
@Override
public void destroyItem(ViewGroup container, int position,
Object object)
{
container.removeView(mImageViews.get(position));
}
@Override
//就是这里一直报错
public boolean isViewFromObject(View view, Object object)
{
return view == object;
}
@Override
public int getCount()
{
return mImgIds.length;
}
});
}
private void initData()
{
for (int imgId : mImgIds)
{
ImageView imageView = new ImageView(getApplicationContext());
imageView.setScaleType(ScaleType.CENTER_CROP);
imageView.setImageResource(imgId);
mImageViews.add(imageView);
}
}
}
public boolean isViewFromObject(View view, Object object)
{
return view == object;
}
改成
public boolean isViewFromObject(android.view.View view, Object object)
{
return view == object;
}
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。