Wie soll ich Vorschlag @mention wie eine Liste in Android zeigen und wie die BilderWie man AutoCompleteTextView wie unten Bild in Android
-2
A
Antwort
0
den Code unten verwenden:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<AutoCompleteTextView
android:id="@+id/autoCompleteTextView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="10"
android:layout_below="@+id/imageView"
android:layout_alignLeft="@+id/imageView"
android:layout_alignStart="@+id/imageView"
android:layout_marginTop="72dp"
android:hint="AutoComplete TextView">
<requestFocus />
</AutoCompleteTextView>
</RelativeLayout>
Java-Code:
AutoCompleteTextView text;
String[] languages={"Android ","java","IOS","SQL","JDBC","Web services"};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
text=(AutoCompleteTextView)findViewById(R.id.autoCompleteTextView1);
ArrayAdapter adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_1,languages);
text.setAdapter(adapter);
text.setThreshold(1);
}
Verwenden Sie diesen Code, um die Ausgabe zu erhalten.
+0
Dies schlägt automatisch nur Strings vor. Wie kann ich Bilder automatisch vorschlagen? – mercury0114
besuchen Sie diese https://androidcookbook.com/Recipe.seam;jsessionid=CAD52F00EA0265C80BDD218165CDDA26?recipeId=827&recipeFrom=ViewTOC – Ironman