我尝试为自定义列表视图设置 OnItemClickListener。我将适配器设置为
final ListView searchlist = (ListView) findViewById(R.id.prodlist);
String[] from = new String[] {"rowid", "col_1", "col_2","col_3"};
int[] to = new int[] { R.id.checkBox1, R.id.editText1, R.id.editText2, R.id.editText3};
//added data to the components using for loop.
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.prod_view,from, to);
list.setAdapter(adapter);
list.setOnItemClickListener(new OnItemClickListener()
{
public void onItemClick(AdapterView<?> arg0, View v, int position, long id)
{
Toast.makeText(Prod.this,"" + position, Toast.LENGTH_SHORT).show();
}
});
但是,当我单击列表视图中的复选框时,它不会显示 toast 消息。在列表视图中选中复选框时,如何获取位置?