I'm using ExpandableListView in fragment, everything works fine until I expand a group that has some selected value (ie in orange-ish color).
Now after expanding a group, for example prayer reminder, it looks like this
Notice that items in red rectangles have switched places.
Here are my getGroupView()
and getChildView()
methods
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.prayer_settings_list_item, parent, false);
}
((TextView) convertView.findViewById(R.id.setting_name_tv)).setText((String) getGroup(groupPosition));
return convertView;
}
@Override
public View getChildView(int groupPosition, final int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.azan_selection_item, parent, false);
MontserratRegTextView azanVoiceMakkahTv = (MontserratRegTextView) convertView.findViewById(R.id.azan_voice_tv);
final ImageView icPlayPause = (ImageView) convertView.findViewById(R.id.azan_play_ic);
icPlayPause.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
PrayerSettingsFragment.listener.onClick(childPosition, icPlayPause);
}
});
String azanVoice = (String) getChild(groupPosition, childPosition);
azanVoiceMakkahTv.setText(azanVoice);
return convertView;
}
嗨,我遇到了同样的问题,我通过从 getGroupView 方法中删除此条件if (convertView == null)
来修复它
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.