/** * Sets the selection to the specified group. * * @param groupPosition * The position of the group that should be selected. */ public void setSelectedGroup(int groupPosition) { mList.setSelectedGroup(groupPosition); }
/** * Sets the selection to the specified group. * * @param groupPosition The position of the group that should be selected. */ public void setSelectedGroup(int groupPosition) { mExpandableList.setSelectedGroup(groupPosition); } }
public class ExpandableListAdapter extends BaseExpandableListAdapter{ private Context context; int group; ExpandableListView expandableListView; public ExpandableListAdapter(Context context,ExpandableListView exp,int grp){ this.context = context; this.expandableListView = exp; this.group = grp; } @Override public View getGroupView(final int listPosition,final boolean isExpanded, View convertView,final ViewGroup parent) { if (convertView == null) { // your code } textview.setText(listTitle); //set view of group before selecting it if(group != -1){ expandableListView.setSelectedGroup(group); } return convertView; } }
expandList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (!parent.isGroupExpanded(groupPosition)) { parent.expandGroup(groupPosition); } else { parent.collapseGroup(groupPosition); } parent.setSelectedGroup(groupPosition); return true; } });
expandList.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() { @Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (!parent.isGroupExpanded(groupPosition)) { parent.expandGroup(groupPosition); } else { parent.collapseGroup(groupPosition); } parent.setSelectedGroup(groupPosition); return true; } });
@Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (sign == -1) { // 选择展开的项 expandableGridView.expandGroup(groupPosition); // 将展开的项置于顶端 expandableGridView.setSelectedGroup(groupPosition); sign = groupPosition; } else if (sign == groupPosition) { // 如果已近展开,则将其折叠 expandableGridView.collapseGroup(groupPosition); sign = -1; } else { // 点击其他选项之前,先将之前的关闭掉 expandableGridView.collapseGroup(sign); expandableGridView.expandGroup(groupPosition); sign = groupPosition; } return true; } });
@Override public boolean onGroupClick(ExpandableListView parent, View v, int groupPosition, long id) { if (expandGroupIndex == -1) { mEl.expandGroup(groupPosition); //设置被选中的group置于顶端 //mEl.setSelectedGroup(groupPosition); expandGroupIndex = groupPosition; } else if (expandGroupIndex == groupPosition) { mEl.collapseGroup(expandGroupIndex); expandGroupIndex = -1; } else { mEl.collapseGroup(expandGroupIndex); //展开被选的group mEl.expandGroup(groupPosition); mEl.setSelectedGroup(groupPosition); expandGroupIndex = groupPosition; } mAdapter.setExpandGroupIndex(expandGroupIndex); long packedPositionForGroup = mEl.getPackedPositionForGroup(groupPosition); // int packedPositionGroup = mEl.getPackedPositionGroup(packedPositionForGroup); int flatListPosition = mEl.getFlatListPosition(packedPositionForGroup); Log.d(TAG, "Group- " + flatListPosition + " - " + packedPositionForGroup); return true; } }
if (otpBundle.isFromInfoWindow()) { elv.expandGroup(otpBundle.getCurrentStepIndex()); elv.setSelectedGroup(otpBundle.getCurrentStepIndex()); otpBundle.setFromInfoWindow(false);
mExpandableListView.setSelectedGroup(arg0);