2013-02-22 1 views
0
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)); 

    } 
내가 목록 위치 0

는 ListActivity에서 찾을 수 없습니다 c.getstring

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(); 
} 
에 누를 때 그것은 나에게 오류를 제공하지 않습니다 컴파일러 onListItemClick에는 getString에서 작동하지 않습니다하지만 충돌 이유를 물어보고 싶은게

안녕 얘들 아 당신이 열 데이터를 얻을 수 있습니다 전에

}

답변

0

당신은 cursor.moveToFirst() 또는 cursor.moveToPosition(int)를 호출해야합니다.