Hello guys i want to ask a question about android intent extras. I am new to Android enviroment.
i have a programm which displays some records from a database to a ListView. How can i retrieve the position of the on itemclicklistener and inn which way i can pass the name the type and the address to other activity?
Here is my code:
public void updateJSONdata() {
barAvalaibleForUserList = new ArrayList<HashMap<String, String>>();
JSONParser jParser = new JSONParser();
JSONObject json = jParser.getJSONFromUrl(SHOW_BARS_URL);
try {
barAvalaibleForUser = json.getJSONArray(TAG_POSTS);
for (int i = 0; i < barAvalaibleForUser.length(); i++) {
JSONObject c = barAvalaibleForUser.getJSONObject(i);
// gets the content of each tag
String name = c.getString(TAG_NAME);
String address = c.getString(TAG_ADDRESS);
String type = c.getString(TAG_TYPE);
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
map.put(TAG_NAME, name);
map.put(TAG_ADDRESS, address);
map.put(TAG_TYPE, type);
barAvalaibleForUserList.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
private void updateList() {
final ListAdapter adapter = new SimpleAdapter(this, barAvalaibleForUserList,
R.layout.layout_list_item, new String[] { TAG_NAME, TAG_ADDRESS,
TAG_TYPE }, new int[] { R.id.bar_name_txt, R.id.bar_address_txt,
R.id.bar_type_txt });
setListAdapter(adapter);
ListView lv = getListView();
lv.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
Intent intent = new Intent(MainActivity.this,CafeInfo.class);
startActivity(intent);
}
});
}