Note that there are some explanatory texts on larger screens.

plurals
  1. POAutoCompleteText issue getting repeated values in list?
    text
    copied!<p><img src="https://i.stack.imgur.com/DIylg.png" alt="enter image description here"></p> <p>Please help me out with this issue:</p> <p>I want to display country and code when i search in the autocomplete text view and its working fine but iam getting twice values rather than single value.</p> <p><strong>MainActivity.java:</strong></p> <pre><code>public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); String[] countries = new String[] { "Allentown", "Albuquerque","Aberdeen","Acapulco","Waco","Atlantic City", "Marka-Amman","Pittsburgh","Augusta","Auckland","Albany", "Amarillo","Amman","Amsterdam","Anchorage","Antwerp", "Naples","Aqaba","Stockholm","Aspen","Asuncion"......}; String[] codes=new String[]{ "ABE","ABQ","AMS","ANC","ANR","APF","AQJ","ARN","ASE","ASU","ATH", .............}; List&lt;HashMap&lt;String,String&gt;&gt; list = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;(); for(int i=0;i&lt;countries.length;i++){ HashMap&lt;String, String&gt; curGroupMap = new HashMap&lt;String,String&gt;(); curGroupMap.put("country", countries[i]); curGroupMap.put("code", codes[i]); list.add(curGroupMap); } final AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.autocomplete_country); SimpleAdapter adapter = new SimpleAdapter(getBaseContext(), list, R.layout.twolist, new String[] {"code","country"}, new int[] { R.id.textView1,R.id.textView2}); textView.setAdapter(adapter); textView.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView&lt;?&gt; p, View v, int pos, long id) { Map&lt;String, String&gt; map = (Map&lt;String, String&gt;) p.getItemAtPosition(pos); String itemName = map.get("code"); textView.setText(itemName); } }); } } </code></pre> <h3>And my xml for getting the listview is <strong>twolist.xml:</strong></h3> <pre><code> &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal" &gt; &lt;TextView android:id="@+id/textView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="TextView" /&gt; &lt;TextView android:id="@+id/a" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" /&gt; &lt;TextView android:id="@+id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:text="TextView" /&gt; </code></pre> <p></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