In my application, I won't use AutoCompleteTextView to complete the word from the array list.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate( savedInstanceState );
setContentView( R.layout.activity_initial_cost );
String[] tipsNameCost=getResources().getStringArray( R.array.name_costs );
editTextCostName=(AutoCompleteTextView) findViewById( R.id.edit_text_initial_cost_name );
ArrayAdapter<String> editTextAdapter=new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,tipsNameCost);
AutoCompleteTextView textView = (AutoCompleteTextView) findViewById(R.id.edit_text_initial_cost_name);
textView.setThreshold(0);
textView.setAdapter(editTextAdapter);
XML
<AutoCompleteTextView
android:id="@+id/edit_text_initial_cost_name"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="4dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:editable="true"
android:inputType="text"
android:ems="10">
<requestFocus/>
</AutoCompleteTextView>
It's work when I click in editTextCostName and I will write the first letter of the word. But I won't do When the user clicks on the editextCostName field, a list with hints to choose from must be displayed immediately. So that he could choose a word from the list. How to do it?
Solution:
You can simple use showDropDown()
like this:
textView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View arg0) {
textView.setMaxLines(5);
textView.showDropDown();
}
});
That's it, Hope it works.