gpt4 book ai didi

android - new AdapterView.OnItemClickListener(){}类型必须实现继承的抽象方法AdapterView.OnItemClickListener)

转载 作者:太空宇宙 更新时间:2023-11-03 12:02:12 25 4
gpt4 key购买 nike

类型new AdapterView.OnItemClickListener(){}必须实现继承的抽象方法AdapterView.OnItemClickListener.onItemClick(AdapterView, View, int, long)

为什么我在尝试构建教程时收到此消息

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();
}
}
);
}
}

最佳答案

改变这个:

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

为此:

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

覆盖 super 方法时,您必须确保所有数据类型都与原始类型匹配。

关于android - new AdapterView.OnItemClickListener(){}类型必须实现继承的抽象方法AdapterView.OnItemClickListener),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3150115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com