我正在使用AutoCompleteTextView
来推荐我的列表,但我希望这些建议是内联的,而不是显示下拉列表。我怎样才能实现这一目标?这是我当前的代码,作为下拉列表:
String[] birds = getResources().getStringArray(
R.array.birds_list);
// Create the adapter and set it to the AutoCompleteTextView
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, birds);
mAutoCompleteTextView.setAdapter(adapter);
mAutoCompleteTextView.setThreshold(1);
mAutoCompleteTextView
.setOnFocusChangeListener(new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
mAutoCompleteTextView.showDropDown();
}
});
mAutoCompleteTextView
.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if ((event != null && (event.getKeyCode() == KeyEvent.KEYCODE_ENTER))
|| (actionId == EditorInfo.IME_ACTION_DONE)) {
Utils.hideSoftKeyboard(AddMedicationActivity.this);
}
return false;
}
});