我想在选择按钮后获取listview的id,但它没有获取id,如何在单击每一行的listview中的按钮时获取id。
public void onPrayComplete(List<Application> data)
{
this.items = data;
// dismiss the progress dialog
if ( dialog != null )
dialog.dismiss();
// create new adapter
ApplicationAdapter adapter = new ApplicationAdapter(this, data);
// set the adapter to list
lv1.setAdapter(adapter);
lv1.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
pray = (Button) view.findViewById(R.id.pray);
//Application bean1 = items.get(position);
/*Object o = lv1.getItemAtPosition(position);
Application obj_itemDetails = (Application)o;
showAlertView(obj_itemDetails+"");
prayerid = obj_itemDetails.getId();*/
Application bean1 = items.get(position);
if (bean1.isSelected()) {
bean1.setSelected(false);
pray.setClickable(false);
} else {
bean1.setSelected(true);
pray.setClickable(true);
}
}
});
}
public void pray(View v) {
StringBuffer sb1 = new StringBuffer();
//showAlertView(sb.toString().trim());
for (Application bean1 : items) {
if (bean1.isSelected()) {
sb1.append("Id:");
sb1.append((bean1.getId()));
}
}
showAlertView(sb1.toString().trim());
//praydata(Integer.parseInt(sb1.toString().trim()));
}
我只想获取 id 并且它必须显示在我的列表视图中,但它没有从我的列表视图中获取 id,如何仅从列表视图中获取 if