在Expandablelistview中,我想根據所選控件在子視圖中更新其中一個groupview圖像,如何完成此操作? 基本上 我想這樣ExpandableListView getGroupView friom子控件
public View getChildview(int groupPosition,final int childPosition, boolean isLastChild, View convertView,ViewGroup parent)
{
View Groupview=parent.getChildAt(groupPosition); ///but gives null when if scrolling the expandablelist
}
編輯 下面的代碼工作我
public View getGroupView(ExpandableListView listView, int groupPosition) {
long packedPosition = ExpandableListView.getPackedPositionForGroup(groupPosition);
int flatPosition = listView.getFlatListPosition(packedPosition);
int first = listView.getFirstVisiblePosition();
return listView.getChildAt(flatPosition - first);
}
會試試這個,有沒有什麼辦法可以訪問適配器類中的listview? –
onChildClick()中的一個參數爲您提供了適配器的列表視圖,這是我推薦它的原因之一;)另外,您將OnChildClickListener設置爲您的ExpandableListview實例化的活動/片段,因此您實際上一個簡單的參考。 (忘了提及OnChildClickListener,將編輯問題) – danieljohngomez
謝謝,我通過引用..公開ExpandListViewAdapter(活動mActivity,ExpandableListView cmgListView)this.mActivity = mActivity; this.mListView = cmgListView; } –