Note that there are some explanatory texts on larger screens.

plurals
  1. PODuplicate data in ListView when Searching
    text
    copied!<p>I'm trying to do search which include images and textview. So when I search it returns the positive result, but when i go back and search with other value it returns the old return and new result at the same time. I want my listView not to add old data into it. I need to over write the old data with a new value. here my code :</p> <pre><code>public void onClick(View Kv) { Intent moreDetailsIntent = new Intent(MainMenu.this,ListMobileActivity.class); Bundle dataBundle = new Bundle(); dataBundle.putString("Prov","KwaZulu-Natal"); moreDetailsIntent.putExtras(dataBundle); startActivity(moreDetailsIntent); }); B_GP.setOnClickListener(new View .OnClickListener() { @Override public void onClick(View Gv) { Intent moreDetailsIntent = new Intent(MainMenu.this,ListMobileActivity.class); Bundle dataBundle = new Bundle(); dataBundle.putString("Prov","Gauteng"); moreDetailsIntent.putExtras(dataBundle); startActivity(moreDetailsIntent); } }); </code></pre> <p>When i click a first buttonKZN it must display all KZN provinces and when click buttonB_GP it must return all GP province. so what it does it just return the old data when i search for the second time, here my listView classess :</p> <pre><code>Bundle b = getIntent().getExtras(); // Getting the Bundle object that pass from another activity String SelectedProv = b.getString("Prov"); List&lt;NameValuePair&gt; params = new ArrayList&lt;NameValuePair&gt;(); params.add(new BasicNameValuePair("ProvinceName",SelectedProv)); Log.d("ProvinceName",SelectedProv); JSONObject json = jsonParser.makeHttpRequest("http://10.0.2.2/php/searchKZN.php", "POST", params); try{ JSONArray earthquakes = json.getJSONArray("PROV"); for(int i=0;i&lt;earthquakes.length();i++){ JSONObject e = earthquakes.getJSONObject(i); String PCity = e.getString("P_City"); PNames.add(PCity); String Pimage = e.getString("Pname"); PImages.add(Pimage); } } catch(JSONException e){ Log.e("log_tag", "Error parsing data "+e.toString()); } setListAdapter(new MobileArrayAdapter(this, PNames,PImages)); </code></pre> <p>So please help me to diplay the correct values according to selected button.</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