开发者社区> 问答> 正文

The method xxx of type new xxxx must override 的问题

The method isViewFromObject(View, Object) of type new PagerAdapter(){} must override or implement a supertype method

网上说的方法: 一、

因为你的Compiler 是jdk1.5,只要把它改为 1.6
方法:

  1. window ->preferences... -> java -> Compiler
  2. Compiler compliance level : 6.0
    二、 把项目的JRE变成6.0的

项目右键->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);  
    }  
}  


}

展开
收起
爵霸 2016-03-26 11:08:43 2355 0
1 条回答
写回答
取消 提交回答
  • public boolean isViewFromObject(View view, Object object)
    
     { 
            return view == object;  
        }  
            改成 
                    public boolean isViewFromObject(android.view.View view, Object object)  
        {  
    
            return view == object;  
        }  
    2019-07-17 19:15:49
    赞同 展开评论 打赏
问答分类:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
AutoAlerts-From Data to Action 立即下载
OPEN SOURCE IN A DATA-DRIVEN WORLD 立即下载
低代码开发师(初级)实战教程 立即下载