1. Introduction :

 

When ever we need to enter any word and a suggestion pop’s up below we feel much more easy and enjoy typing in mobile especially when we are busy in chatting this process most of them use this suggestion turned on.

So, now a similar mechanism we will be implementing in our app i.e., AutoCompleteTextView the name gives the complete description about what we are going to do……

We will be getting necessary suggestion from the TextView while we are entering the text / word.And one more thing i want to specify here is that we will not be using regular TextView here but a similar type of view which is called as to be AutoCompleteTextView, yes its the name of the text input we are going to use it here in autocompletetextview in android tutorial.

 

2. Creating activity_main.xml :

 

In this tutorial we will be using a textview which appears to be a normal text view but its got a feature to show suggestions as we type on So lets see it first,

 

 

Yes that’s it we gonna need here but in a formal way look at full code.

 

 

And then here comes our java code where we will be going to use the above textview to get the suggestion shown up.

3. Creating MainActivity.java :

Initialize the AutoCompleteTextView

 

 

Then we will be using a String Array to set some data and attach it to textview so that it will show up in suggestions.

 

 

So now we will be binding the data to the AutoCompleteTextView using a android autocompletetextview arrayadapter

 

 

Full CodeĀ  for MainActivity.java

 

4. Output :

 

autotextview1 autotextview2



Share article on

Show Buttons
Hide Buttons

June 25, 2017

Attention Required! | Cloudflare

One more step

Please complete the security check to access push.wppush.co

Why do I have to complete a CAPTCHA?

Completing the CAPTCHA proves you are a human and gives you temporary access to the web property.

What can I do to prevent this in the future?

If you are on a personal connection, like at home, you can run an anti-virus scan on your device to make sure it is not infected with malware.

If you are at an office or shared network, you can ask the network administrator to run a scan across the network looking for misconfigured or infected devices.

table
Clear all
Read previous post:
Android replace a string by another

Close