Android: Automatically complete text boxes
The xml file code is as follows:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:andro android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <AutoCompleteTextView android: android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
The java file code is as follows:
package .sample_5_1; import .; import ; import ; import ; public class AutoCompleteActivity extends AppCompatActivity { private static final String[] myStr = new String[]{ "vae","victory","vision","virtue","vital" }; @Override protected void onCreate(Bundle savedInstanceState) { (savedInstanceState); setContentView(.activity_auto_complete); ArrayAdapter<String> aa = new ArrayAdapter<String>( //Create an adapter this, // Context .simple_dropdown_item_1line, //Use the simple layout that comes with Android myStr); //Resource array AutoCompleteTextView myAutoCompleteTextView = (AutoCompleteTextView) findViewById(); //Get the reference to the control (aa); //Set the adapter (1); //Define the number of characters that need to be entered by the user } }
The above example of Android automatic text box completion is all the content I share with you. I hope you can give you a reference and I hope you can support me more.