serlioner
19/04/14, 22:16:52
Hola, estoy tratando de personalizar un Listview para mostrar una base de datos, pero me da error, si pudieseis ayudarme me haríais un gran favor, estoy bastante mareado con el asunto, dejo el código de mi adapter:
public class AdaptadorCursorLugares extends CursorAdapter{
private LayoutInflater inflador;
TextView nombre, repeticiones, series;
public AdaptadorCursorLugares(Context contexto, Cursor c)
{
super(contexto,c,false);
}
public View getView(Context contexto, Cursor c, ViewGroup padre)
{
inflador = (LayoutInflater) contexto
.getSystemService(Context.LAYOUT_INFLATER_SERVICE) ;
View vista = inflador.inflate(R.layout.vistas, padre, false);
return vista;
}
@Override
public void bindView(View vista, Context contexto, Cursor c) {
nombre = (TextView) vista.findViewById(R.id.nombre);
series = (TextView) vista.findViewById(R.id.series);
repeticiones = (TextView) vista.findViewById(R.id.repeticiones);
nombre.setText(c.getString(1));
series.setText(c.getString(2));
repeticiones.setText(c.getString(3));
}
@Override
public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
return null;
}
}
En el MainActivity lo llamo así:
adaptador = new AdaptadorCursorLugares(this, c); //siendo c un cursor.
Espero ansioso vuestra respuesta (llevo pocas semanas con android, así que pido por adelantado disculpa por los fallos).
public class AdaptadorCursorLugares extends CursorAdapter{
private LayoutInflater inflador;
TextView nombre, repeticiones, series;
public AdaptadorCursorLugares(Context contexto, Cursor c)
{
super(contexto,c,false);
}
public View getView(Context contexto, Cursor c, ViewGroup padre)
{
inflador = (LayoutInflater) contexto
.getSystemService(Context.LAYOUT_INFLATER_SERVICE) ;
View vista = inflador.inflate(R.layout.vistas, padre, false);
return vista;
}
@Override
public void bindView(View vista, Context contexto, Cursor c) {
nombre = (TextView) vista.findViewById(R.id.nombre);
series = (TextView) vista.findViewById(R.id.series);
repeticiones = (TextView) vista.findViewById(R.id.repeticiones);
nombre.setText(c.getString(1));
series.setText(c.getString(2));
repeticiones.setText(c.getString(3));
}
@Override
public View newView(Context arg0, Cursor arg1, ViewGroup arg2) {
// TODO Auto-generated method stub
return null;
}
}
En el MainActivity lo llamo así:
adaptador = new AdaptadorCursorLugares(this, c); //siendo c un cursor.
Espero ansioso vuestra respuesta (llevo pocas semanas con android, así que pido por adelantado disculpa por los fallos).