我在listItemClick上的列表項內部放大視圖。列表項包含一個複選框。單擊複選框時,包含兩個/三個編輯文本字段和按鈕的線性佈局會被充氣到該列表視圖(通過遊標適配器的getView方法完成,動態創建充氣視圖)。在列表視圖中插入單個視圖使listItem不可點擊
列表視圖在項目點擊監聽器上註冊。在佈局被充氣後,onItemClick監聽器不會被調用特定的項目。幫我
我getView代碼
TextView text1 = (TextView) view.findViewById (R.id.text);
text1.setText("text");
CheckBox cb = (CheckBox)view.findViewById(R.id.checkBoxList) ;
cb.setTag(tag);
cb.setChecked(false);
if (chekedIdVector.contains(cursor.getString(cursor.getColumnIndex(ID))))
{
cb.setChecked(true);
}
if(!idVector.isEmpty())
{
LinearLayout ll =(LinearLayout)view.findViewById(R.id.layoutinCell);
if (((String)idVector.lastElement()).equals(cursor.getString(cursor.getColumnIndex(_ID))))
{
if (ll.getChildCount() == 0)
{
ll.removeAllViews() ;
ll.addView(dynamicallyCreatedView); // view dynamically created with 2/3 textviews and buttons
}
ll.setVisibility(View.VISIBLE);
view.requestFocus() ;
}
else
{
ll.removeAllViews() ;
}
}
return view ;
PS:我已經在專注試圖改變監聽器,並設置複選框以非可聚焦在XML
請檢查此[post](http://meta.stackexchange.com/a/5235/176658) – nandeesh
什麼是'view'?你如何在'view'裏搜索'LinearLayout',然後添加'view'作爲這個'LinearLayout'的子節點? 'view'不能同時是'll'的父母和孩子。 – user113215
@ user113215該視圖是遊標適配器中getView()方法的參數。子視圖是個動態創建視圖。我已編輯它:-) – arul