0
我需要在列表視圖中添加一個組件,如listitem。 我已經添加了使用佈局充氣機的組件。 現在的問題是我無法獲得listitems的onitemclick。 如何讓列表中的項目點擊和其他列表項目組件點擊。如何在列表視圖中使用組件並獲取列表項單擊,還可以單擊組件?
我需要在列表視圖中添加一個組件,如listitem。 我已經添加了使用佈局充氣機的組件。 現在的問題是我無法獲得listitems的onitemclick。 如何讓列表中的項目點擊和其他列表項目組件點擊。如何在列表視圖中使用組件並獲取列表項單擊,還可以單擊組件?
的點擊列表視圖使用此
lv.setClickable(true);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
Object o = lv.getItemAtPosition(position);
/* write you handling code like...
String st = "sdcard/";
File f = new File(st+o.toString());
// do whatever u want to do with 'f' File object
*/
}
});