Skip to content
Coding Fanatic
  • Android Development
  • News and Reviews
  • Road2Pro
  • Tutorials
  • Services
  • About

Houston, We Have Input! 54/100 Days of Code

  • December 5, 2019January 9, 2020
  • by Richard Clarke

I figured out how to get input using an EditText layout!

I added an OnEditorActionListener to the EditText layout in the Search Activity. Now the app can utilize the input entered by users. You can find a video at the bottom of the page and a link to the source code here.

My first step was to update the xml layout for the Search Activity. I added the android:imeOptions attribute and set the value to actionDone. In the Search Activity, I invoked the setOnEditorActionListener() method on the editText object and overrode the onEditorAction() method. I added logic which adds another String to the ArrayAdapter object depending on the content of the EditText.

The android:imeOptions attribute configures the enter key on the bottom right of the keyboard when it is open. By setting it to actionDone, a key appears which closes the keyboard when pressed.

Overriding the onEditorAction() method allowed me to configure what happens when a user presses the enter key on the keyboard. In this case, if the user types the text “Dave”, pressing the enter key will append the String “Chappelle” to the list of addresses on screen.

This was pretty straightforward. Not too different from setting up an onClickListener. The only difference I see is that I need to configure what happens based on the action performed when the user presses enter on the keyboard.

I’m going to stop here for a while. I want to update the way the ArrayAdapter for the addresses is used. Instead of containing a list of Strings, I want to use the objects themselves. This will make it easier to update the list programmatically.

For more on this, watch the YouTube video below. For the source code click here

Join the mailing list to see updates like this every week!
Coding Fanatic

Related

Capital Idea…Or Not 53/100 Days of Code
Objects Are a Real Trip, 55/100 Days of Code
Richard Clarke
Richard is currently a developer using Java and Android Studio to build custom applications for Android. Richard tutored in mathematics at Montgomery College, and worked in Information Technology before entering the Software Development industry as a Quality Engineer.
100daysofcode Android AndroidDev Java

Related articles

Your New Favorite Stopwatch App!…
Two for Two BABY! 7…
…But the App is for…
Play Store Blues – 5…
Top 4 Tips for Android…
No Dice – 3 of…

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • GitHub
  • YouTube
  • X
  • Instagram
  • LinkedIn
My Tweets

Join the mailing list!

This field is required.

Check your inbox or spam folder to confirm your subscription.

Follow me on social media!

  • X
  • GitHub
  • LinkedIn
  • YouTube

Archives

Theme by Colorlib Powered by WordPress