简体   繁体   中英

The type new AdapterView.OnItemClickListener(){} must implement the inherited abstract method AdapterView.OnItemClickListener)

The type new AdapterView.OnItemClickListener(){} must implement the inherited abstract method AdapterView.OnItemClickListener.onItemClick(AdapterView, View, int, long)

Why i get this message when i tried to build the tutorial

package Fedail.Hello.Layout;

import android.app.Activity;
import android.os.Bundle;
import android.widget.*;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;


public class Layout_Feras extends Activity {
    /** Called when the activity is first created. */

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setAdapter(new ImageAdapter(this));

        gridview.setOnItemClickListener(new OnItemClickListener(){
         public void onItemClick(AdapterView<?> parent, View v, int position, Long id){
          Toast.makeText(Layout_Feras.this,"" + position, Toast.LENGTH_SHORT).show();
         }
        }
        );
    } 
}

Change this:

public void onItemClick(AdapterView<?> parent, View v, int position, Long id)

to this:

public void onItemClick(AdapterView<?> parent, View v, int position, long id)

When overriding a super method you will have to make sure all datatypes match the original types.

onItemClick()您的Long更改为long ,看看是否有帮助。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM