Android - expandablelistview

 
Vista:

expandablelistview

Publicado por cizallo (1 intervención) el 30/11/2016 23:08:22
Buenas Tardes.

Necesito usar un expandiblelistview, para mostrar datos de una tabla en sqlite; tengo las 2 tablas ( uno para la cabecera y el otro el detalle), al hacer click en la cabecera se deberá mostrar el detalle, el detalle tiene un formato especial, para lo cual debo usar un adapter.
Por favor si alguien tuviera un ejemplo de como usar este tipo de listview con sqlite.

Consultando, algunos ejemplos en internet pude armar este código. Pero al ejecutar me sale el error siguiente:

E/CursorWindow: Failed to read row 0, column -1 from a CursorWindow which has 1 rows, 1 columns.
11-30 16:18:32.280 31350-31350/com.itptovta.itteam.itptovta D/AndroidRuntime: Shutting down VM
11-30 16:18:32.290 31350-31350/com.itptovta.itteam.itptovta E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.itptovta.itteam.itptovta, PID: 31350
java.lang.IllegalStateException: Couldn't read row 0, col -1 from CursorWindow. Make sure the Cursor is initialized correctly before accessing data from it.
at android.database.CursorWindow.nativeGetLong(Native Method)





private void Levantar_Datos(Context context) {

Mesa_Cursor = helper.Grupo_Mesa();
startManagingCursor(Mesa_Cursor);

Mesa_Cursor.moveToFirst();


if (Mesa_Cursor.getCount() > 0 ) {

Mesa_Cursor.moveToFirst();

xzona = Mesa_Cursor.getColumnIndexOrThrow("ZONA");


MyExpandableListAdapter mAdapter = new MyExpandableListAdapter(Mesa_Cursor, this,
R.layout.mesa,
R.layout.hijo_mesa,
new String[]{"ZONA"},
new int[]{R.id.repomesa},
new String[]{"CANT", "PRODUCTO","OBS1","OBS2","ROW_ID"},
new int[]{R.id.cantidad, R.id.producto, R.id.obs1, R.id.obs2, R.id.row_id});

elv.setAdapter(mAdapter);

}
}

public class MyExpandableListAdapter extends SimpleCursorTreeAdapter {

public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {

super(context, cursor, groupLayout, groupFrom, groupTo,
childLayout, childrenFrom, childrenTo);
}


@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {

Cursor childCursor = helper.Detalle_Mesa(String.valueOf(groupCursor.getInt(0)));////"16");//groupCursor.getString(0));
startManagingCursor(childCursor);
childCursor.moveToFirst();
return childCursor;
}

}


De antemano les agradezco el apoyo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder