Reputation: 12316
Can i set setOnItemClickListener if i can't make list view.setonitemcliclistener because mi xml code is
<ListView
android:id="@android:id/list"
android:cacheColorHint="#666666"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="verLugarClick"
/>
and my code
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listatab);
//Creamos la instancia de DataBaseHelper, un cursor y aplicamos el metodo getNombres al cursor y llamamos al metodo encargado de gestioanr ese cursor
ayudabbdd = new DataBaseHelper(this);
Cursor nombresC;
nombresC = (Cursor) ayudabbdd.getNombres();
nombresC.moveToFirst();
startManagingCursor(nombresC);
//Para crear un simpleCursorAdapter necesitamos
//Contexto this
//Layour donde se mostrara el resultado, generalmente un textview
//Cursor
//Cual sera el campo que recibiremos de la BBDD
//Donde tenemos que poner esa informacion, generalmente el ID correspondiente al textvies del layour del segundo parametro
String[] from = new String[]{DataBaseHelper.CNOMBRE};
int[] to = new int[]{R.id.nombreLugar};
SimpleCursorAdapter lugares =
new SimpleCursorAdapter(this, R.layout.entrada_lista, nombresC, from, to);
setListAdapter(lugares);
}
I have a cursor from a bbdd and to saw the results in a listview i must to set ndroid:id="@android:id/list", and for this i can't use the method findviewbyid
Upvotes: 0
Views: 448
Reputation: 14700
You can use android.R.id.list
to get the ListView
:
ListView listView = (ListView) findViewById(android.R.id.list);
Upvotes: 1