0

的Android的ListView我創建使用 setOnItemClickListener當它不工作的時候,將主要從SQLite數據庫提取數據,並使用SimpleCursorAdapter與SimpleCursorAdapter

我的問題是出現一個ListView的應用程序。

這裏是我的活動

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_categoria); 
    //Mostrando lista 
    dbcon = new SQLController(this); 
    dbcon.open(); 
    lv = (ListView) findViewById(R.id.listView1); 

    Cursor cursor = dbcon.readData(); 
    String[] from = new String[] { DBhelper.MEMBER_ID, DBhelper.MEMBER_NAME }; 
    int[] to = new int[] { R.id.tv_descripcion, R.id.tv_Titulo }; 

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(Categoria.this, 
      R.layout.fila, cursor, from, to);    
    adapter.notifyDataSetChanged(); 
    lv.setAdapter(adapter); 


    //Fin de mostrar lista 
    Log.d("jose", "Salio del Adapter"); 
    //Click en el elemento de la lista 
    lv.setOnItemClickListener(new OnItemClickListener() { 
     @Override 
     public void onItemClick(AdapterView<?> parent, View view, 
       int position, long id) { 
      Log.d("jose", "Toco la lista"); 
      Toast.makeText(getApplicationContext(), "tocado", Toast.LENGTH_SHORT).show() 
     } 
    });  



} 

回答

0

onCreate事件這是很簡單的實際。工作你只需要在xml中添加一行描述行。在botonoes XML屬性添加

機器人:可調焦= 「假」

和問題就解決了。由於setOnItemClick funsiona列表視圖