Duplicate value issue in MultiAutoCompleteTextView

≯℡__Kan透↙ 提交于 2019-12-24 03:49:09

问题


I am new to android development and i am using MultiAutoCompleteTextView in my APP and following is code.

public TextView autoSelected;
String[]    countries   =   {"India","USA","Canada","Indonesia","Belgium", "France", "Italy", "Germany", "Spain"};
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    MultiAutoCompleteTextView   autoCompleteTextView    =   (MultiAutoCompleteTextView)findViewById(R.id.autoCompleteTextView);     

    ArrayAdapter<String>    adapter     =   new ArrayAdapter<String>(this,android.R.layout.simple_dropdown_item_1line,countries);
    autoCompleteTextView.setAdapter(adapter);
    autoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());


}

First Problem and main problem TextView is getting duplicate values means same country is showing in TextView again and again. Example: i can select USA from autocomplete n number of times and it is showing n times in text field.

I want if i already selected specific value from suggestion, in that case either it should not visible in suggestions or it should not be visible in TextView.

Second issue

I want to customize design of selected values that are currently in TextView like with background and close sign attached to it.

来源:https://stackoverflow.com/questions/27165431/duplicate-value-issue-in-multiautocompletetextview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!