Android:输入空格后隐藏Autocompletetextview下拉列表

时间:2015-08-28 05:59:53

标签: java android android-arrayadapter

我创建了一个AutoCompleteTextView下拉列表,其中包含多行中的单词,如 -

row 1 - Infosys Limited
row 2 - State Bank of India

当我进入Infosys时,当我在下拉菜单关闭后进入空间时,它可以正常工作。

ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, GreenDaoUtils.getSSSymbolNamesArray(this));
autoCompleteTextView.setAdapter(adapter);
autoCompleteTextView.setLines(8);
autoCompleteTextView.setDropDownBackgroundDrawable(getResources().getDrawable(R.drawable.cust_rect_border));
autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(final AdapterView<?> parent, final View view, final int position, long id) {

        });
    }
});

1 个答案:

答案 0 :(得分:0)

使用 FilterWithSpaceAdapter 代替ArrayAdapter

你来自FilterWithSpaceAdapter here

  FilterWithSpaceAdapter<String> adapter1;
  adapter1 = new FilterWithSpaceAdapter<String>(this, android.R.layout.simple_list_item_1, GreenDaoUtils.getSSSymbolNamesArray(this));