HOW TO CREATE AND USE AUTOCOMPLETETEXTVIEW IN ANDROID KOTLIN | ANDROID KOTLIN AUTO COMPLETE TEXTVIEW

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my channel today in this video tutorial we are going to learn about how to complete text view and android code lens so let's start so i have created this project in which i have this uh activityman.xml and this man activity.kt files so we have this text simple autocomplete android cortland on this uh designer so now i will drag in a autocomplete text view here it is a present in this text section so i'll drag this here and now i'll pin it to this side as well as this side and i'll pin it to the top as well and it will take 70 margins from the top now i'll go to whom our main activity.kt file and here i will connect that autocomplete textview here but first we will create an array of countries here so i'll use wall countries equals and here i will use array of and i will pass in the element so the first element i will pass is pakistan then i will pass in india then i will pass in iran then i will pass in iraq then i'll pass in saudi arabia then i'll pass in sudan then i'll pass in usa then i will pass in uk and then i'll pass in another country u a e so i think this is enough now i'll uh come here and here i'll connect that autocomplete here equals find you by rd so auto complete text view and here i will use r dot id dot auto complete text view i will check the id so i'll go to code and here is the id how to complete text view 2 so i'll go to not design but this auto complete text to and now i'll create in an adopter so i'll use war um adopter array equals array adopter and here it will take a context so i'll give it application context or you can give it this because we are in the context of main activity or main activity dot this and i'll pass in the resource so i'll pass on the default android resource android dot r dot layout dot simple spinner drop down item and here i will pass in the array so i will pass in countries now our adapter is uh created so we will set this array adapter to our autocompletes or to complete dot set adapter and i will use adopter array and now here i will use autocomplete dot sit on item click list now so here it will take on item click listener the second one and now i'll go toward the end of this after this arrow and here we will show the toast toast dot make text and it will take a context so i will pass in the application context comma and then it will take the value so here i will use collect item equal and i will use plus countries and uh position and now i'll use toast dot then short and dot show and now if i run this quickly so now the application is running and we have this text in it so i will quickly fix this so for that i will go to this activity man dot xml code and now i'll come here and i'll remove this uh uh text and i'll make this uh hint and i'll use enter country name and now we will rerun it again so now the application is running so if i enter u s and it will give me the suggestion and similarly if you enter s a so it give me the suggestion of saudi arabia now we will add in a button and we will get this value from this autocomplete text so for that i will quickly come to this design and here i will search for button i'll come to these buttons and i will drag in this button and uh now i'll append it to this autocomplete open it from the top here and now i'll make the margins 32 and uh to this side as well as to this side and now i'll go to code and here i will connect that button here so i'll use a wall button equals find view by id button and i'll use r dot id dot button and now we will add the click listener to this button so button dot sit on click list now and uh you would use a view on dot on on click listener and now here i can get that value so i'll use toast dot mac text and the application context comma and value is equal and then plus and then auto dot text dot to string comma toast dot length short and dot show and now i will quickly run this again now the application is running again so if i enter here serve saudi arabia so ayu and if i select this so the arabian now if i click on this button we'll use saudi arabia and similarly if i enter pakistan and select this now if i click on this button when you use pakistan so that's all for today i hope you liked the video if you liked the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 31
Rating: undefined out of 5
Keywords: Programming Guru, programming, autocompletetextview in android studio, autocompletetextview, autocompletetextview kotlin, autocomplete textview android kotlin, kotlin android autocompletetextview, kotlin course for beginners, kotlin tutorial for beginners, kotlin basics for beginners, how to create and use autocompletetextview in android kotlin, android autocompletetextview, android autocompletetextview dropdown, autocompletetextview android, autocompletetextview example
Id: 9ZChIN9LveM
Channel Id: undefined
Length: 9min 29sec (569 seconds)
Published: Thu Dec 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.