我使用CursorTreeadapter
使用来自sql数据库的数据来膨胀ExpandableListView
,但它无法正常工作,我希望你能帮助我。
public class ExplistviewAdapter extends CursorTreeAdapter {
Context mContext;
public ExplistviewAdapter(Cursor cursor, Context context) {
super(cursor, context);
mContext = context;
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
return groupCursor;
}
@Override
protected View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = layoutInflater.inflate(R.layout.borderslayout,parent, false);
return view;
}
@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean isExpanded) {
//bind existing views with data from cursor ...
TextView measuredate = (TextView) view.findViewById(R.id.datumTF);
//.......
//......
}
@Override
protected View newChildView(Context context, Cursor cursor, boolean isLastChild, ViewGroup parent) {
final View view = LayoutInflater.from(context).inflate(R.layout.child_view, parent, false);
TextView nameTV = (TextView) view.findViewById(R.id.textView11);
return view;
}
@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean isLastChild) {
//bind existing views with data from cursor ...
Textview existingview = (Textview) view.findViewById(R.id.existingviewTV);
//......
//.....
}
}
问题:我使用通过rawQuery从sql数据库收到的游标初始化Class。光标有例如3行:
cursorROW1: measuredateROW1 LastnameRow1 SurnameRow1
cursorROW2: measuredateROW2 LastnameRow2 SurnameRow2
cursorROW3: measuredateROW3 LastnameRow3 SurnameRow3
initialization
的{{1}}工作正常,而Groupview
的{{1}}使用不同的测量值ExpandableListview
。tableEntries
但是当我展开tableEntries
每个Childview
包含来自不同Lastname
的每个cursorRows
和姓氏时:
measuredateRow1
- LastnameRow1 SurnameRow1
- LastnameRow2 SurnameRow2
- LastnameRow3 SurnameRow3
measuredateRow2
- LastnameRow1 SurnameRow1
- LastnameRow2 SurnameRow2
- LastnameRow3 SurnameRow3
measuredateRow3
- LastnameRow1 SurnameRow1
- LastnameRow2 SurnameRow2
- LastnameRow3 SurnameRow3
但我想要遵循以下行为
measuredateRow1
- LastnameRow1 SurnameRow1
measuredateRow2
- LastnameRow2 SurnameRow2
measuredateRow3
- LastnameRow3 SurnameRow3
我怎样才能做到这一点?
最好的问候。