Позиции не по порядку Custom BaseExpandableListAdapter
Пытаюсь сделать расширенный список на основе ExpandableListView, соответственно использую кастом адаптер.
Но по какой то причине, после запуска, когда я начинаю крутить список вверх, вниз, список отображается не по порядку, т.е. первый в alGroups.address отображаемый = например "ELDORADO", второй = "LENTA", и так далее, но после прокрутки, первый и второй могут отображаться на какой угодно позиции.
Где я ошибся в коде?
public class SmsItemInfo {
public final int id;
public final String date;
public final String address;
public final String body;
public final String guid;
public final boolean uploaded;
public SmsItemInfo(int id, String date, String address, String body, String guid, boolean uploaded) {
this.id = id;
this.date = date;
this.address = address;
this.body = body;
this.guid = guid;
this.uploaded = uploaded;
}
package com.dkmm.smsparser.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.CheckBox;
import android.widget.TextView;
import com.dkmm.R;
import com.dkmm.constants.SmsItemInfo;
import java.util.ArrayList;
public class AdapterSmsListEx extends BaseExpandableListAdapter {
private ArrayList<SmsItemInfo> alGroups;
private ArrayList<ArrayList<SmsItemInfo>> alChildrens;
private Context context;
private LayoutInflater inflater;
public static class TagSmsItem {
public int id;
public String date;
public String address;
public String body;
public String guid;
public boolean uploaded;
public CheckBox chkUploaded;
public TextView tvAddress;
public TextView tvBody;
}
public AdapterSmsListEx(Context context, ArrayList<SmsItemInfo> alGroups, ArrayList<ArrayList<SmsItemInfo>> alChildrens) {
this.context = context;
this.alGroups = alGroups;
this.alChildrens = alChildrens;
this.inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getGroupCount() {
return alGroups.size();
}
@Override
public int getChildrenCount(int groupPos) {
return alChildrens.get(groupPos).size();
}
@Override
public Object getGroup(int groupPos) {
return alGroups.get(groupPos);
}
@Override
public Object getChild(int groupPos, int childPos) {
return alChildrens.get(groupPos).get(childPos);
}
@Override
public long getGroupId(int groupPos) {
return groupPos;
}
@Override
public long getChildId(int groupPos, int childPos) {
return childPos;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public View getGroupView(int groupPos, boolean b, View convertedView, ViewGroup parent) {
TagSmsItem tagSmsItem;
try {
tagSmsItem = new TagSmsItem();
SmsItemInfo smsItemInfo = alGroups.get(groupPos);
if (convertedView == null) {
convertedView = inflater.inflate(R.layout.view_sms_address_list, null);
tagSmsItem.id = smsItemInfo.id;
tagSmsItem.date = smsItemInfo.date;
tagSmsItem.address = smsItemInfo.address;
tagSmsItem.body = smsItemInfo.body;
tagSmsItem.guid = smsItemInfo.guid;
tagSmsItem.uploaded = smsItemInfo.uploaded;
tagSmsItem.tvAddress = (TextView) convertedView.findViewById(R.id.tvSmsAddress);
tagSmsItem.chkUploaded.setChecked(tagSmsItem.uploaded);
convertedView.setTag(tagSmsItem);
} else {
tagSmsItem = (TagSmsItem) convertedView.getTag();
}
tagSmsItem.chkUploaded = (CheckBox) convertedView.findViewById(R.id.chkUploadAddress);
tagSmsItem.tvAddress.setText(tagSmsItem.address + " - " + Integer.toString(groupPos));
// раскрываем группу
//ExpandableListView mExpandableListView = (ExpandableListView) parent;
//mExpandableListView.expandGroup(groupPos);
} catch (Exception e) {
return null;
}
return convertedView;
}
@Override
public View getChildView(int groupPos, int childPos, boolean isLastChild, View convertedView, ViewGroup parent) {
TagSmsItem tagSmsItem;
try {
tagSmsItem = new TagSmsItem();
SmsItemInfo smsItemInfo = alChildrens.get(groupPos).get(childPos);
if (convertedView == null) {
convertedView = inflater.inflate(R.layout.view_sms_list_item, null);
tagSmsItem.id = smsItemInfo.id;
tagSmsItem.date = smsItemInfo.date;
tagSmsItem.address = smsItemInfo.address;
tagSmsItem.body = smsItemInfo.body;
tagSmsItem.guid = smsItemInfo.guid;
tagSmsItem.uploaded = smsItemInfo.uploaded;
tagSmsItem.tvAddress = (TextView) convertedView.findViewById(R.id.tvSmsAddress);
tagSmsItem.tvBody = (TextView) convertedView.findViewById(R.id.tvSmsBody);
tagSmsItem.chkUploaded = (CheckBox) convertedView.findViewById(R.id.chkUploadSms);
convertedView.setTag(tagSmsItem);
} else {
tagSmsItem = (TagSmsItem) convertedView.getTag();
}
tagSmsItem.tvAddress.setText(smsItemInfo.address);
tagSmsItem.tvBody.setText(smsItemInfo.body);
tagSmsItem.chkUploaded.setChecked(smsItemInfo.uploaded);
} catch (Exception e) {
return null;
}
return convertedView;
}
@Override
public boolean isChildSelectable(int i, int i1) {
return true;
}
}

