Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You need to defined another item in the xml layout(listitem) for address,which you will fetch via R.id.address</p> <p>Later on you're going to fetch this below the description view</p> <pre><code> ListAdapter adapter = new SimpleAdapter(this, contactList, R.layout.list_item, new String[] { TAG_NAME, TAG_EMAIL, TAG_PHONE_MOBILE,TAG_ADDRESS }, new int[] { R.id.name, R.id.email, R.id.mobile,R.id.address }); setListAdapter(adapter); // selecting single ListView item ListView lv = getListView(); // Launching new screen on Selecting Single ListItem lv.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { // getting values from selected ListItem String name = ((TextView) view.findViewById(R.id.name)).getText().toString(); String cost = ((TextView) view.findViewById(R.id.email)).getText().toString(); String description = ((TextView) view.findViewById(R.id.mobile)).getText().toString(); //this is where you fetch address String address= ((TextView) view.findViewById(R.id.address)).getText().toString(); // Starting new intent Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class); in.putExtra(TAG_NAME, name); in.putExtra(TAG_EMAIL, cost); in.putExtra(TAG_PHONE_MOBILE, description); in.putExtra(TAG_ADDRESS, address); startActivity(in); } }); </code></pre> <p><strong>EDIT:</strong> If you do not want to use extra resources then this is what you can do:</p> <p>Declare an <code>ArrayList</code> on the class level like:</p> <pre><code>ArrayList() addArr = new ArrayList() </code></pre> <p>Then add addresses to this array inside the forloop:</p> <pre><code>String email = c.getString(TAG_EMAIL); String address = c.getString(TAG_ADDRESS); String gender = c.getString(TAG_GENDER); addArr.add(address); </code></pre> <p>Then when you are fetching the address inside the itemClickListener just put this code</p> <pre><code> in.putExtra(TAG_ADDRESS, addArr.get(position)); </code></pre> <p>That should do it inshallah</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload