How to auto fill an edit text in android applicati

2019-05-14 13:26发布

问题:

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...

回答1:

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



回答2:

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"


回答3:

I Dont get u clearly.. Sooo. If u want to show text that which user has to fill use Hint.

 android:hint="Enter any Filpcart Item"

OR If u need auto complete text then use above link @kumaand.