Ich benutze MultiAutoCompleteTextView
für die Anzeige von Vorschlägen, während ich etwas eintippe. Ich setze MultiAutoCompleteTextView
in eine AlertDialog
. Jetzt wird das Drop-down-Menü nicht angezeigt.MultiAutoCompleteTextView zeigt kein Dropdown in AlertDialog
Mein xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity=""
android:orientation="vertical"
android:padding="20dp">
<TextView
android:id="@+id/tv_query_statement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:textColor="@color/colorTextWhite"/>
<MultiAutoCompleteTextView
android:id="@+id/et_query"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:focusableInTouchMode="true"
android:padding="10dp"
android:textColor="@color/colorTextWhite"/>
<android.support.v7.widget.AppCompatButton
android:id="@+id/btn_submit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:padding="10dp"
android:text="Submit"
android:textColor="@color/colorTextWhite"/>
</LinearLayout>
Innen Aktivität
private void setupQueryDialog() {
final AlertDialog.Builder dialog = new AlertDialog.Builder(getActivity());
View view = LayoutInflater.from(getContext()).inflate(R.layout.layout_query_dialog, null);
AppCompatButton btnsubmit = (AppCompatButton) view.findViewById(R.id.btn_submit);
final MultiAutoCompleteTextView mQueryEditor = (MultiAutoCompleteTextView) view.findViewById(R.id.et_query);
TextView mQueryStatement = (TextView) view.findViewById(R.id.tv_query_statement);
String[] commands = QueryHelper.getAllSqlCommands(mTableDetailSource);
ArrayAdapter<String> adapter = new ArrayAdapter<>(getActivity(), android.R.layout.simple_spinner_item, commands);
mQueryEditor.setThreshold(1);
mQueryEditor.setAdapter(adapter);
mQueryEditor.showDropDown();
mQueryEditor.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
/*if (editable.toString().length() > 0)
mQueryEditor.showDropDown();*/
}
});
dialog.setView(view);
final Dialog d = dialog.create();
btnsubmit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
submitQuery(mQueryEditor.getText().toString());
d.dismiss();
}
});
dialog.show();
}
Ich habe das Problem gefunden und es war 'mQueryEditor.setTokenizer (new MyCustomTokenizer)'. Und danke für die teure Antwort. – Godwin