为什么setOnClickListener()不适用于GridView(AdapterView)

时间:2013-11-28 06:19:01

标签: android

当我尝试为GridView(AdapterView)设置click侦听器时,程序崩溃和Logcat:“不要为AdapterView调用setOnClickListener”。

添加:为什么机制(Adapterview无法在点击时调用)像这样工作?

2 个答案:

答案 0 :(得分:0)

尝试使用onItemClick

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

Added in API level 1
Callback method to be invoked when an item in this AdapterView has been clicked.

Implementers can call getItemAtPosition(position) if they need to access the data associated with the selected item.

答案 1 :(得分:0)

您应该尝试setOnItemClickListener函数。

相关问题