OnItemClickListener 不适用于 BaseAdapter

Ahm*_*tef -2 android baseadapter onitemclick

我正在尝试将可点击列表添加到我的第一个带有自定义适配器的 android 应用程序中,一切都很好,但是当我使用时

mItemList.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                long id) {
            // TODO Auto-generated method stub
            Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_LONG).show();
            Log.d("error", "error here");   
        }
    });
Run Code Online (Sandbox Code Playgroud)

但是没有响应没有吐司没有错误尽管列表显示良好

定制适配器

 public class ItemListAdapter extends BaseAdapter {
public Context context;
public ArrayList<ItemModel> items;
.....
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View grid;
LayoutInflater mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (convertView == null ) {
        grid = new View(context);
        grid = mInflater.inflate(R.layout.item, null);
Button bt = (Button) grid.findViewById(R.id.btn_list);
    Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/font1.otf");
 bt.setText(items.get(position).getTitle().toString());
 bt.setTypeface(tf);
}else{
    grid = (View) convertView;
}
return grid;
}
....
}
Run Code Online (Sandbox Code Playgroud)

Ali*_*jad 5

如果你有ButtonImageButtonCheckBoxRadioButton您的项目布局中,添加这些属性对他们说:

android:focusable="false"
android:focusableInTouchMode="false"
Run Code Online (Sandbox Code Playgroud)