EditText can sometimes be a way of communicating with applications. Generally, EditTexts are used to fill in information or queries by the user and execute some tasks. Once the text is typed, the information or the query can be passed in the background to make things available or do some operations. But to pass it, there should be some method like if the user stops typing, accept the typed text, or use a button instead to pass the info.
This is quite similar to a Search Bar. A Search Bar originally is an application of EditText, where users can type something and click the search button on the screen or from the invoked keyboard. By nature, the invoked keyboard does not come with a search button. A developer has to program it in such a way that a search icon appears on the invoked keyboard.

So through this article, we will show you how you should configure your EditText such that you are able to show the Search Icon along with other options available in Android.
Step by Step Implementation
Step 1: Create a New Project
To create a new project in Android Studio please refer to How to Create/Start a New Project in Android Studio.
Step 2: Create EditText element in the activity_main.xml (Layout file)
While creating one, remember to put these configuration tags.
- android:imeOptions=”actionSearch”
- android:inputType=”text”
Check the code below:
XML
<? xml version = "1.0" encoding = "utf-8" ?>
< androidx.constraintlayout.widget.ConstraintLayout
android:layout_width = "match_parent"
android:layout_height = "match_parent"
tools:context = ".MainActivity" >
< EditText
android:layout_width = "match_parent"
android:layout_height = "wrap_content"
android:hint = "Type something ...."
android:gravity = "center"
android:imeOptions = "actionSearch"
android:inputType = "text"
tools:ignore = "MissingConstraints" />
</ androidx.constraintlayout.widget.ConstraintLayout >
|
Output:
Now run the application and start typing in the edit text, or simply click on it once. Keyboard gets invoked and you can see the search option at the bottom.

Similarly, we have the following options in Android to replace the existing one:
1. Go
android:imeOptions=”actionGo“

2. Send
android:imeOptions=”actionSend“

3. Done
android:imeOptions=”actionDone“

4. Next
android:imeOptions=”actionNext“

5. Previous
android:imeOptions=”actionPrevious“

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
18 Jul, 2021
Like Article
Save Article