Programación y Desarrollo para Android Subforo exclusivo para temas de programación de software para PDAs y desarrollo de aplicaciones, interfaces, etc bajo Android

Respuesta
 
Herramientas
  #1  
Viejo 21/12/13, 14:24:24
Array

[xs_avatar]
Impulselp Impulselp no está en línea
Usuario novato en la web
 
Fecha de registro: dic 2013
Mensajes: 1
Modelo de smartphone: Galaxy S3
Tu operador: Movistar
Problema al desarrollar mi aplicacion

Buenas tardes estoy cambiando mi aplicación de tener un Adapter a un Cursor adapter, pero no se si lo que estoy haciendo esta bien, y en el oncreate no se que debo hacer os adjunto el codigo, tambien me aparecen las sentencias que he puesto en negritas tachadas y no se porque. Muchas gracias por adelantado.

public class TravelListActivity extends ListActivity {

private class TravelAdapter extends CursorAdapter{


private final Context context;

public TravelAdapter(Context context,Cursor c) {
super.TravelAdapter(context, layout, c, from, to);

// TODO Auto-generated constructor stub
}


@Override

public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
View v = inflater.inflate(android.R.layout.simple_list_item _2, parent, false);

ViewHolder holder = new ViewHolder();

holder.text1 = (TextView) v.findViewById(android.R.id.text1);
holder.text2 = (TextView) v.findViewById(android.R.id.text2);
v.setTag(holder);

return v;

}
public void bindView(View view, Context context, Cursor cursor) {

ViewHolder holder = (ViewHolder)view.getTag();

holder.text1.setText(cursor.getColumnIndex(Travels .CITY) + " (" + cursor.getColumnIndex(Travels.COUNTRY) + ")");
holder.text2.setText(getResources().getString(R.st ring.year) + " " + cursor.getColumnIndex(Travels.YEAR));

}
public View getView(int position, View convertView, ViewGroup parent) {
if (!mDataValid) {
throw new IllegalStateException("this should only be called when the cursor is valid");
}
if (!mCursor.moveToPosition(position)) {
throw new IllegalStateException("couldn't move cursor to position " + position);
}
View v;
if (convertView == null) {
v = newView(mContext, mCursor, parent);
} else {
v = convertView;
}
bindView(v, mContext, mCursor);
return v;
}

}

static class ViewHolder {
TextView text1;
TextView text2;
}

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

Cursor Cursor = this.managedQuery(TravelsProvider.CONTENT_URI, null, null, null, null);
this.setListAdapter(new TravelAdapter(this,Cursor));

initialData();

registerForContextMenu(getListView());
}
Responder Con Cita


Respuesta

Estás aquí
Regresar   Portal | Indice > Todo sobre Android > Programación y Desarrollo para Android

Herramientas


Hora actual: 01:24:37 (GMT +2)



User Alert System provided by Advanced User Tagging (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.

Contactar por correo / Contact by mail / 邮件联系 /