Делая просмотр списка, который будет расширяться с большим количеством данных по клику, что я не понял? - PullRequest
0 голосов
/ 02 марта 2020

за весь день, который я пытался выяснить это, также нужно сказать, что я только что начал с android. Как на фотографии: xmlPreview Я хочу сделать простой список (синяя часть), который будет расширяться за счет дополнительной информации из sqliteDB.

Я пытался следовать учебным пособиям для Expandable RecyclerView, Теперь я попытался исследовать ExpandableListView, но безуспешно.

Что я хочу спросить, что я должен продолжать искать, или даже если эти вещи выполнимы? Разве ExpandableListView не является ответом? Вот что я пытался сделать, но безуспешно:

public class CursorAdapter extends CursorTreeAdapter {

Context mcontext;
public CursorAdapter(Cursor cursor, Context context) {
    super(cursor, context);
    mcontext = context;
}

@Override
protected Cursor getChildrenCursor(Cursor cursor) {
    return cursor;
}

@Override
protected View newGroupView(Context context, Cursor cursor, boolean isExpanded, ViewGroup viewGroup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.layout_expandableView, viewGroup, false);
    return v;
}

@Override
protected void bindGroupView(View view, Context context, Cursor cursor, boolean b) {
    TextView name = view.findViewById(R.id.tv_name);
    name.setText(cursor.getString(2));
    TextView lastname = view.findViewById(R.id.tv_lastname)
    lastname.setText(cursor.getString(3));
}

@Override
protected View newChildView(Context context, Cursor cursor, boolean b, ViewGroup viewGroup) {
    LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.layout_expandableView, viewGroup,false);
    return v;
}

@Override
protected void bindChildView(View view, Context context, Cursor cursor, boolean b) {
    TextView tvData = view.findViewById(R.id.tv_data);
    tvData.setText(cursor.getString(1));
}

}

Об основной деятельности:

Cursor c = DBAdapter.getUsers();
    expandableListView = v.findViewById(R.id.elv);
    CursorAdapter = new Adapter(c, getContext());
    expandableListView.setAdapter(favoritesCursorAdapter);

Если ответ ExpandableListView, где я могу найти дополнительную документацию о том, как правильно ее реализовать?

...