Mam AutoCompleteTextView, która jak zwykle podaje sugestie po wpisaniu przez użytkownika 3 liter. Chcę raz dotknąć listy sugestii, aby ukryć miękką klawiaturę. Co zrobiłem poniżej z układem tabeli, ukrywa klawiaturę tylko wtedy, gdy klikniesz w dowolnym miejscu oprócz listy sugestii.Android: AutoCompleteTextView ukryj miękką klawiaturę
XML
<TableRow
android:id="@+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<AutoCompleteTextView
android:id="@+id/auto_insert_meds"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="15"
android:inputType="textVisiblePassword|textMultiLine"
android:scrollHorizontally="false"
android:text=""
android:textSize="16sp" />
</TableRow>
Java
TableLayout tbl = (TableLayout) findViewById(R.id.main_table);
tbl.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
InputMethodManager in = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
in.hideSoftInputFromWindow(v.getWindowToken(), 0);
return true;
}
});
XML dla niestandardowej listy
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/medlist_linear_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/med_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollHorizontally="false"
android:padding="3dp"
android:textColor="@android:color/white" />
</LinearLayout>
Zachowanie chcesz wymusić nie jest to, co użytkownik może oczekiwać. Zły interfejs użytkownika ... –
Nie, nie jest, użytkownik kliknął żądany element.Nie ma potrzeby, aby klawiatura była widoczna. – Denny