我正在进行一个带有自定义列表视图的警告对话框,但onItemClickListener不起作用,我不知道为什么。这是我的代码:
ListView lv = (ListView) view.findViewById(R.id.listView1);
MyAdapter clad = new MyAdapter(MyFragment.this, mi);
lv.setAdapter(clad);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position,
long id) {
String titulo = ((TextView) view.findViewById(R.id.label))
.getText().toString();
if (position==0){
Toast.makeText(getApplicationContext(),
"Button is clicked", Toast.LENGTH_LONG).show();
}
}
});
dialog.setContentView(view);
dialog.show();
}
});