yes, AutocompleteTextview is a view component which is not available in our Palette controls. directly we have to write in our layout .xml file. inside Relatielayout of activity_main.xml
<AutoCompleteTextView
android:id="@+id/AutoCompleteView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:completionThreshold="3"
</AutoCompleteTextView>
here we given threshold at design time itself, or runtime also set this threshold value.
AutoCompleteTextview : is an EditText with autocomplete funcationality. this is achived using Adapter.adapter acts a bridge between edittext and underlaying data/values. adapter is responsible for view each item in that dataset.
1st way i utilized predefined android.R.layout.simple_list_item_1 Style for showing items in Autocompletetextview.
2nd way i designed one layout file as Root element is TextView---mystyle.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#f00"--------->red color so that values(india,indonisa) showing in red color.
android:textSize="16sp"
android:padding="12dp" >
</TextView>
Externalizing values : it defines a file with resources as an string-array named as countries.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="country">
<item>India</item>
<item>Indonesia</item>
<item>Iran</item>
<item>Iraq</item>
<item>Ireland</item>
<item>Poland</item>
<item>Pakistan</item>
<item>Peru</item>
</string-array>
</resources>
<AutoCompleteTextView
android:id="@+id/AutoCompleteView1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:completionThreshold="3"
</AutoCompleteTextView>
here we given threshold at design time itself, or runtime also set this threshold value.

AutoCompleteTextview : is an EditText with autocomplete funcationality. this is achived using Adapter.adapter acts a bridge between edittext and underlaying data/values. adapter is responsible for view each item in that dataset.
1st way i utilized predefined android.R.layout.simple_list_item_1 Style for showing items in Autocompletetextview.
2nd way i designed one layout file as Root element is TextView---mystyle.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#f00"--------->red color so that values(india,indonisa) showing in red color.
android:textSize="16sp"
android:padding="12dp" >
</TextView>
Externalizing values : it defines a file with resources as an string-array named as countries.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="country">
<item>India</item>
<item>Indonesia</item>
<item>Iran</item>
<item>Iraq</item>
<item>Ireland</item>
<item>Poland</item>
<item>Pakistan</item>
<item>Peru</item>
</string-array>
</resources>
No comments:
Post a Comment