程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> 編程綜合問答 >> android-The method xxx of type new xxxx must override 的問題

android-The method xxx of type new xxxx must override 的問題

編輯:編程綜合問答
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);  
    }  
}  

}

最佳回答:


竟然自己解決了,雖然不知道原因,哈哈哈!!誰能給解釋下;
public boolean isViewFromObject(View view, Object object)

{

        return view == object;  
    }  

            改成 
                public boolean isViewFromObject(android.view.View view, Object object)  
    {  

        return view == object;  
    }  

就可以了,我是先刪除原來的override,按提示自動添加未重寫的方法,系統自動寫出來的。

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved