ExpandableListView getGroupView friom子控件
ExpandableListView getGroupView friom child control
在可扩展列表视图中,我想根据子视图中选定的控件更新其中一个组视图图像,如何实现??
基本上
我想要这样
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);
}
getGroupView() – Returns view for the list group header
getChildView() – Returns view for list child item
So u must create/inflate view in getChildView method
更多详情:
http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/
我建议使用 OnChildClickListener 并覆盖 onChildClick() 并使用此 code 获取父视图。
在可扩展列表视图中,我想根据子视图中选定的控件更新其中一个组视图图像,如何实现?? 基本上 我想要这样
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);
}
getGroupView() – Returns view for the list group header
getChildView() – Returns view for list child item
So u must create/inflate view in getChildView method
更多详情:
http://www.androidhive.info/2013/07/android-expandable-list-view-tutorial/
我建议使用 OnChildClickListener 并覆盖 onChildClick() 并使用此 code 获取父视图。