在 ListView 的 OnClickListener 上做这样的事情
LV.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
myDialog = new Dialog(Dealer_data.this);
myDialog.setContentView(R.layout.detail_dealer);
myDialog.getWindow().setLayout(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
myDialog.setTitle("Dealer Details");
myDialog.setCancelable(true);
TextView t1;
t1 = (TextView) myDialog.findViewById(R.id.textView1);
int a=1;
int add_pos= position+a;
//Toast.makeText(getApplicationContext(), "Position after add= "+add_pos, Toast.LENGTH_LONG).show();
deal_id=""+add_pos;
pos = new ArrayList<String>();
Cursor col =dbCarHelper.getdealer(deal_id);
for (col.moveToFirst(); !col.isAfterLast(); col.moveToNext()) {
// The Cursor is now set to the right position
pos.add(col.getString(0));
pos.add(col.getString(1));
pos.add(col.getString(2));
pos.add(col.getString(3));
pos.add(col.getString(4));
pos.add(col.getString(5));
pos.add(col.getString(6));
pos.add(col.getString(7));
pos.add(col.getString(8));
pos.add(col.getString(9));
// pos.add(col.getString(10));
}
full_detail = "Car Make : " + pos.get(0) + "\nState : " + pos.get(1)
+ " \nCity : " + pos.get(2) + "\nCompany Name : " + pos.get(3)
+ "\nCompany Address : " + pos.get(4) + "\nPhone : " + pos.get(5)
+ "\nMobile : " + pos.get(6) + "\nFax : " + pos.get(7)
+ "\nEmail : " + pos.get(8) + "\nWebsite : " + pos.get(9);
t1.setText(full_detail);
myDialog.show();
}
});