2012-07-19 79 views
1

在我的應用程序中,我在列表視圖中顯示數據表單數據庫。如果用戶單擊特定的行,我必須獲取這4個文本視圖值,我有列表視圖中有4個文本視圖。請幫幫我。在android中的列表視圖檢索

+0

你在listview中只有4行? – AkashG 2012-07-19 11:28:38

+0

這個鏈接將幫助你。 – Venkatesh 2012-07-19 11:35:55

回答

0

試試這個,

list.setOnItemClickListener(new OnItemClickListener() { 

     public void onItemClick(AdapterView<?> parent, View view, int position, 
       long id) { 

      String textview1 = ((TextView) view.findViewById(R.id.text1)).getText().toString(); 
      String textview2 = ((TextView) view.findViewById(R.id.text2)).getText().toString(); 
      String textview3 = ((TextView) view.findViewById(R.id.text3)).getText().toString(); 
      String textview4 = ((TextView) view.findViewById(R.id.text4)).getText().toString(); 

     } 
    }); 
+0

這裏TextView作爲你的列表視圖。這是在這裏工作。 – Venkatesh 2012-07-19 11:32:19

+0

感謝它的工作...... – 2012-07-19 11:39:15

1

你需要做什麼是由數據庫值保持四面陣列表 創建這些您獲取 和列表項單擊 獲得各個項目的價值像

@Override 
    public void onItemClick(AdapterView<?> arg0, View arg1, int position, 
      long id) { 
     // TODO Auto-generated method stub 


    String s1 = ArrayList1.get(position); 

    String s2 = ArrayList2.get(position); 

    String s3 = ArrayList3.get(iposition); 

    String s4 = ArrayList4.get(position); 





    } 
});