如何禁用AutocompleteTextView建议?

时间:2016-07-30 11:22:37

标签: android autocompletetextview

if (cbIsGap.isChecked() == true) {

            Toast.makeText(getActivity(),"Please uncheck Is Gap", Toast.LENGTH_LONG).show();


        }else{
            try {
                Cursor c = db.rawQuery("Select ConsAcNo From FieldUtilityData Where ConsAcNo like '%" + txtConsAcNo.getText() + "%' Limit 15 ", null);

                //Cursor c = db.rawQuery("SELECT * FROM FieldUtilityData  ",null);

                final String[] str = new String[c.getCount()];

                int i = 0;

                if (c.moveToFirst()) {
                    do {
                        //assing values
                        String column2 = c.getString(0);
                        str[i] = c.getString(0);
                        i++;

                    } while (c.moveToNext());
                }
                c.close();

                ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),
                        android.R.layout.simple_dropdown_item_1line, str);
                adapter.setNotifyOnChange(true);

                txtConsAcNo.setAdapter(adapter);
            } catch (Exception e) {

            }
        }

以上是我的代码。 现在我想要的是当复选框被选中时我不想显示自动完成建议。但就我而言,它的显示建议

1 个答案:

答案 0 :(得分:0)

您可以将阈值增加到200-300

myView.setThreshold(300);

当您想要显示下拉列表时,请将其更改回

myView.setThreshold(1);myView.setThreshold(2);根据需要。

这不是确实这样做的方法,而是一种肯定会起作用的黑客,