public class SimpleCursorAdapterConLogoActivity extends ListActivity
{
private DatabaseHelper databaseHelper;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
databaseHelper = new DatabaseHelper(this);
Cursor c = databaseHelper.getAllSiti();
startManagingCursor(c);
System.out.println("SimpleProvinceSimpleCursorAdapter con logo");
setListAdapter(new ProvinceSimpleCursorAdapter(this, c));
}
大家好,我想问一下为什么它在 getstring onListItemClick 中不起作用,编译器没有给我错误,但是当我按下列表位置 0 时它崩溃了
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
final int index = position;
databaseHelper = new DatabaseHelper(this);
Cursor c = databaseHelper.getAllSiti();
startManagingCursor(c);
//You can add whatever you want to happen when you click here
Log.i("testy", "I Clicked on Row " + index + " and it worked!");
switch (index){
case 0:
{
Cursor c1 = databaseHelper.getAllSiti();
startManagingCursor(c1);
String nomeRegione = c.getString(c.getColumnIndex(SitiTable.NOME));
System.out.println(nomeRegione);
//System.out.println(nomeRegione);
}
break;
case 1:
System.out.println("hello2");
break;
case 2:
System.out.println("hello£");
break;
}
}
@Override
protected void onDestroy()
{
super.onDestroy();
databaseHelper.close();
}
}