我使用以下代码来处理gridview(稍微修改自http://developer.android.com/resources/tutorials/views/hello-gridview.html).我想用它们的"触摸"等价物替换onClicklistener和onClick()方法,即touchlistener和onTouch(),这样当我触摸gridview中的元素时,元素的图像会发生变化,并且同一个元素上的双击会接受它回到原始状态.
我该怎么做呢?我无法让我的代码执行此操作.clicklistener在某种程度上起作用,但触摸不是.请帮忙.
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes …Run Code Online (Sandbox Code Playgroud)