Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to auto fill an edit text in android application?

I am developing one android application. In which I have some Products and form to purchase that product. In the Order form I have one Edit Text as Product ( means product name) .

In my application user has to type Product name but I want to know that Is there any way that the EditText field is autofilled with that particular Product like as in flipcart.

Any one knows then suggest me...

Thanks in advance...

like image 818
Abhay Avatar asked Dec 27 '22 13:12

Abhay


2 Answers

When you want to populate it just call (after reading it in from the XML layout in this example):

EditText myTextBox = (EditText) findViewById(R.id.editBox);
myTextBox.setText("My Product Description");

If what you are looking for is an auto completion after they have started typing, then an AutoCompleteTextView is your best bet, replacing the EditText and providing the auto complete functionality

There is an example of this over at the Android Developers website: http://developer.android.com/guide/topics/ui/controls/text.html#AutoComplete

like image 179
biddulph.r Avatar answered Jan 15 '23 11:01

biddulph.r


you can use autocomplete textview for suggestion of your all the product names, refer this example http://saigeethamn.blogspot.in/2010/05/auto-complete-text-view-android.html

or you just want to show when app launches, use hint

android:hint="@string/enterproduct"
like image 26
kumar_android Avatar answered Jan 15 '23 10:01

kumar_android