![]() |
|
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 |
«
Tema Anterior
|
Siguiente tema
»
|
Herramientas |
#1
|
||||
|
||||
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()); } |
|
Respuesta |
![]() |
||||||
|
«
Tema Anterior
|
Siguiente tema
»
|
|
Hora actual: 20:29:48 (GMT +2)
HTCMania: líderes desde el 2007