如何禁用 AutocompleteTextView 建议?
How to disable AutocompleteTextView Suggestion?
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) {
}
}
以上是我的代码。 现在我想要的是当复选框被选中时我不想显示自动完成建议。但就我而言,它显示了建议
您可以将阈值提高到 200-300
myView.setThreshold(300);
当您想显示下拉菜单时,将其改回
myView.setThreshold(1);
或 myView.setThreshold(2);
根据需要。
这不是正确的做法,而是一种绝对有效的 hack,
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) {
}
}
以上是我的代码。 现在我想要的是当复选框被选中时我不想显示自动完成建议。但就我而言,它显示了建议
您可以将阈值提高到 200-300
myView.setThreshold(300);
当您想显示下拉菜单时,将其改回
myView.setThreshold(1);
或 myView.setThreshold(2);
根据需要。
这不是正确的做法,而是一种绝对有效的 hack,