0
private void populateListView(){
Cursor c = loginDataBaseAdapter.allData();
startManagingCursor(c);
String[] fromfields = new String[]{"_id", "NAME", "YEAR", "GENRE"};
int[] toViewIDs = new int[]{R.id.TVmovieID, R.id.TVmovieTtile, R.id.TVmovieYear, R.id.TVmoviegenre};
SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this, R.layout.mlayout, c, fromfields, toViewIDs);
lv.setAdapter(myCursorAdapter);
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s = parent.getItemAtPosition(position).toString();
Toast.makeText(Proba.this, "String"+s, Toast.LENGTH_SHORT).show();
}
});
}
這是我把這個活動的onCreate的方法,我用吐司只是爲了確保即時得到正確的價值,但我得到了android.database.sqlite ... 。我想獲得只有一個領域的價值,但首先我想獲得整個列表的價值。實施Android Studio中獲得價值了列表視圖
投'parent.getItemAtPosition(位置)''來... Cursor'然後用它 – Selvin
它的工作,我用整數i = cursor.getInt( 1);因爲我需要第一列(id)的值。謝謝。 – SixStringSamurai