multiautocompletetextview下拉列表未显示

时间:2013-04-09 19:18:34

标签: android

我正在创建自己的键盘,并使用mMultiAuto.setText将每个字母放入MultiAutoCompleteTextView中。我已经按照创建

的所有教程进行了操作
mMultiAuto = (MultiAutoCompleteTextView)findViewById( R.id.multiautotextview );
    adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    mMultiAuto.setAdapter(adapter);  
    mMultiAuto.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

问题是当我在textview中输入一个字母时,下拉列表没有显示。有人可以帮忙吗?

1 个答案:

答案 0 :(得分:3)

使用以下

替换您的代码
mMultiAuto = (MultiAutoCompleteTextView)findViewById( R.id.multiautotextview );
        adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
        mMultiAuto.setAdapter(adapter);  

                            mMultiAuto.setThreshold(1);

                            mMultiAuto.setAdapter(soAdapter);

                            mMultiAuto.setOnTouchListener(new View.OnTouchListener() {

                                @Override
                                public boolean onTouch(View v, MotionEvent event) 
                                {
                                    mMultiAuto.showDropDown();
                                    return false;
                                }
                            });