Autocompletetextview android example :
Autocompletetextview android example is very useful to show the related values to the entered text. So, the user can easily set the values to the field.
1)Create Auto Completed Textview field in Xml layout,
<AutoCompleteTextView
android:id="@+id/Months"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dip"
android:textStyle="bold"
android:width="250dip" />
|
2)Create String[] values to set with the AutocompletedTextView,
String item[]={
"Monday", "Tuesday", "Wednesday", "Thursday","Friday", "satureday", "Sunday"};
|
3)Create ArrayAdpter to set the String[] values into the AutocompletedTextView,
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, item); |
4)set the String[] values into the AutoCompletedTextView,
textView.setAdapter(adapter); |
5)Implements OnItemClickListener to get the selected item values,
Toast.makeText(getBaseContext(), "Position:"+arg2+" Month:"+arg0.getItemAtPosition(arg2), Toast.LENGTH_LONG).show(); |
Screenshot:
No comments:
Post a Comment