Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid listview onselect item has two values, how to get it separately
    text
    copied!<p>I have a <code>ListView</code> which is populated by getting data from mysql db... the <code>ListView</code> contains three values from the database...</p> <ol> <li>name</li> <li>category</li> <li>position</li> </ol> <p>and I want to pass these values to the next <code>Activity</code>. So I used </p> <pre><code>list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String items = parent.getItemAtPosition(position).toString(); Intent intent = new Intent(); intent.setClass(mapping, CheckIn.class); intent.putExtra("name", items); startActivity(intent); } }); </code></pre> <p>But it produces an array {name = xxx , category = asdasd , position = ddxxddxx} </p> <p>In the 2nd <code>Activity</code>, I want to get user comments about that specified name and insert it to another table. how to do so with the array?</p> <p>the full code</p> <pre><code>try { HttpParams params = new BasicHttpParams(); HttpConnectionParams.setSoTimeout(params, 0); HttpClient httpClient = new DefaultHttpClient(params); // prepare the HTTP GET call HttpGet httpget = new HttpGet("http://hopscriber.com/place.php"); // get the response entity HttpEntity entity = httpClient.execute(httpget).getEntity(); if (entity != null) { // get the response content as a string String response = EntityUtils.toString(entity); // consume the entity entity.consumeContent(); // When HttpClient instance is no longer needed, shut down the // connection manager to ensure immediate deallocation of all // system resources httpClient.getConnectionManager().shutdown(); // return the JSON response ArrayList&lt;HashMap&lt;String, String&gt;&gt; contactList = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;(); JSONArray jsonArray = new JSONArray(response); if (jsonArray != null) { for (int i = 0; i &lt; jsonArray.length(); i++) { JSONObject object = (JSONObject) jsonArray.get(i); HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); map.put(TAG_Name, object.getString("name")); map.put(TAG_Category, object.getString("category")); contactList.add(map); } } ListAdapter adapter = new SimpleAdapter(this, contactList, R.layout.menu_list_row, new String[] { TAG_Name, TAG_Category }, new int[] { R.id.LR_Name, R.id.LR_date }); list.setAdapter(adapter); } } catch (Exception e) { e.printStackTrace(); } // Launching new screen on Selecting Single ListItem list.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) { String items = parent.getItemAtPosition(position).toString(); Intent intent = new Intent(); intent.setClass(mapping, CheckIn.class); intent.putExtra("name", items); startActivity(intent); } }); } </code></pre>
 

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