我猜我的問題很簡單
我要實現的功能代碼如下:
public class AndroidSQLite extends Activity { private SQLiteAdapter mySQLiteAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ListView listContent = (ListView)findViewById(R.id.contentlist);
mySQLiteAdapter = new SQLiteAdapter(this);
mySQLiteAdapter = new SQLiteAdapter(this);
mySQLiteAdapter.openToRead();
Cursor cursor = mySQLiteAdapter.queueAll();
startManagingCursor(cursor);
String[] from = new String[]{SQLiteAdapter.KEY_NOME};
int[] to = new int[]{R.id.text};
SimpleCursorAdapter cursorAdapter =
new SimpleCursorAdapter(this, R.layout.row, cursor, from, to);
listContent.setAdapter(cursorAdapter);
mySQLiteAdapter.close();
}
}
請幫忙。謝謝
試試:
listContent.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapter, View arg1,
int position, long id) {
Log.i("get ItemIDPosition",
"" + adapter.getItemIdAtPosition(position));
Log.i("get ItemATPosition", "" + adapter.getItemAtPosition(position));
}
});