Hello everyone and thanks in advance!
I have a listview that displays a list of name from the sqlite database. What I want to know is how can I make it so that when I click on an Item in the list, it takes me to a new activity which displays the rest of the columns in the Sqlite Table?
This is the method I used to bind the listview with the cursor:
public void displayListView() {
Cursor cursor = dataSource.findAll();
String[] columns = new String[]{
DBHelper.CHARACTERATTRIBUTES_NAME,
DBHelper.CHARACTERATTRIBUTES_NICKNAME,
DBHelper.CHARACTERATTRIBUTES_NOTES};
int[] to = new int[]{
R.id.name,
R.id.nickname,
R.id.notes};
SimpleCursorAdapter dataAdapter = new SimpleCursorAdapter(this, R.layout.character_info, cursor, columns, to, 0);
ListView listView = (ListView) findViewById(R.id.list);
listView.setAdapter(dataAdapter);
listView.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Aucun commentaire:
Enregistrer un commentaire