I want to get different values when I click different list items in my ListView. For example; when code=1 I want to get different values, when code=2 I want to get different values. How can I do this?
Here is my code.
Element e = (Element) nl.item(i);
map.put(KEY_CODE, conParser.getValue(e, KEY_CODE));
map.put(KEY_NAME, conParser.getValue(e, KEY_NAME));
map.put(KEY_COVERS, conParser.getValue(e, KEY_COVERS));
map.put(KEY_TABLE, conParser.getValue(e, KEY_TABLE));
map.put(KEY_SALES, conParser.getValue(e, KEY_SALES));
items.add(map);
}
final ListAdapter adapter = new SimpleAdapter(this, items,
R.layout.list_item,
new String[] {KEY_CODE,KEY_NAME,KEY_COVERS,KEY_TABLE,KEY_SALES},
new int[] {R.id.kod, R.id.name,R.id.person,R.id.table,R.id.sale});
setListAdapter(adapter);
ListView list= getListView();
reportList.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
startActivity(new Intent(NewActivity.this,SingleNewActivity.class));
}
});
It’s not clear what you want, but I figure out that you want to get the clicked item.
So in the onItemClick method the parent parameter is the current list. So what you have to do is get the adapter from the list, and then get the item clicked and you know that because you have the position. So basically you have to write inside the onItemClick this:
And you get the item selected so depending on the item instance you will get the id value for example.
Best