The Wayback Machine - https://web.archive.org/web/20240913224600/https://www.geeksforgeeks.org/invoking-search-button-in-keyboard-while-typing-in-edittext-in-android/
Open In App

Invoking Search Button in Keyboard While Typing in EditText in Android

Last Updated : 18 Jul, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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.

  1. android:imeOptions=”actionSearch”
  2. android:inputType=”text”

Check the code below:

XML




<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
    xmlns:tools="http://schemas.android.com/tools"
    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“



Similar Reads

How to Check Typing Status of EditText in Android?
In this article, we are going to implement an important and quite interesting feature. While Chatting with your friends over various social media platforms you may have found that if your friend is typing something then it shows Typing. Here are going to implement the same. While we start typing something, It will show typing, and when we erase eve
2 min read
How to PopUp DatePicker While Clicking on EditText in Android?
In android applications date pickers are used to pick the date from the calendars and display them within our text view. Many times we have to display this date picker dialog box by clicking on edit text and then we have to display that date within our edit text. In this article, we will take a look at How to Pop Up a Date Picker Dialog in the andr
4 min read
How to Search an Item in ListView using EditText and TextWatcher in Android?
Some applications provide a search bar for looking up any particular item from a list of items. Technically, a search bar is an EditText and an item list can be a ListView, RecyclerView, or a GridView that contains some items. Now, when a user types something in the EditText, the list must update in accordance with the text that the user types. Str
3 min read
Android EditText in Kotlin
EditText is used to get input from the user. EditText is commonly used in forms and login or registration screens. Following steps are used to create EditText in Kotlin: Add a EditText in activity_main.xml file.Add a Button in activity_main.xml file.Open MainActivity.kt file and set OnClickListener for the button to get the user input from EditText
3 min read
EditText widget in Android using Java with Examples
Widget refers to the elements of the UI (User Interface) that helps user interacts with the Android App. Edittext is one of many such widgets which can be used to retrieve text data from user. Edittext refers to the widget that displays an empty textfield in which a user can enter the required text and this text is further used inside our applicati
4 min read
How to Add Mask to an EditText in Android?
EditText is an android widget. It is a User Interface element used for entering and modifying data. It returns data in String format. Masking refers to the process of putting something in place of something else. Therefore by Masking an EditText, the blank space is replaced with some default text, known as Mask. This mask gets removed as soon as th
3 min read
Theming of Material Design EditText in Android with Example
Prerequisite: Material Design EditText in Android with Examples In the previous article Material Design EditText in Android with Examples Material design Text Fields offers more customization and makes the user experience better than the normal text fields. For example, Icon to clear the entire EditText field, helper text, etc. In this article, it'
4 min read
Key Properties of Material Design EditText in Android
In the previous article Material Design EditText in Android with Examples its been discussed how to implement the Material design EditText and how they differ from the normal EditText. In this article its been discussed on how to customize MDC edit text fields with their key properties. Have a look at the following image to get the idea about the k
4 min read
How to Customize AppCompat EditText in Android?
The EditText is one of the important UI element which takes the data as input from the user. The usual EditText in Android which looks decent enough has only the hint text and line which makes the user click on that line and insert the data. Refer to the article EditText widget in Android using Java with Examples, which explains basics about the no
4 min read
Working With the EditText in Android
EditText is one of the basic UI widgets, which is used to take the input from the user. The EditText is derived or is the extension of the TextView in Android. This article its been discussed in detail about the EditText in Android. The article also contains some of the redirections to other articles, also refer to them to get the detailed perspect
9 min read
How to Make TextView and EditText Selectable in Android?
In this article, we are going to implement a very important feature related to TextView. While using any social media app or like using Facebook you may have seen there is a particular type of TextView which you cannot copy like a caption that people write on their posts. You can select the message but there few texts which cannot select or copy. S
3 min read
How to Set Restriction For URL in Android EditText?
In this article, we are going to set restrictions in our EditText for URL. Whenever we are creating any form and we want to get the portfolio website of the user or even if we want to restrict the user to write the only URL then we can use this feature. This enables a user to user to write URL only. Step By Step Implementation Step 1: Create a New
2 min read
How to Stop EditText from Gaining Focus at Activity Startup in Android?
When working on an Android Project, you might face a hazy error, the activity starts, and then the EditText immediately gets the focus and the soft keyboard is forced open. Well, that's not something that we expect, and let's address this, and get rid of it! Method #1: Removing the Request Focus from the EditText You may force override the focus of
2 min read
How to Set Minimum and Maximum Input Value in EditText in Android?
In Android, EditText is a subclass of TextView which is configured to be editable. EditText is used for giving textual input such as characters, strings, numbers, etc. It has no limitation on the type of input unless explicitly attributed. Meaning we can attribute the EditText to accept only a string or a number. On top of this, we can create metho
3 min read
Restrict EditText Input to Some Special Characters in Android
In some of the other applications, most of us must have witnessed that while typing in some field, we get a warning or a flash message that certain characters are not allowed or are not accepted as valid input. For example, sometimes, while renaming a file or a folder in Windows, if we simply type in '?', we get a message that '?' is not accepted a
2 min read
How to Change Input Type of EditText Programmatically in Android?
EditText in Android UI or applications is an input field, that is used to give input text to the application. This input text can be of multiple types like text (Characters), number (Integers), etc. These fields can be used to take text input from the users to perform any desired operation. Let us say, a login activity in our application comprises
3 min read
How to Disable Copy Functionality in EditText in Android?
In Android, EditText is used to let users type in text that can be numbers, characters, strings, or a paragraph. Data from EditText can be fetched and used to perform desired operations. As the primary input of an EditText is text, it can be manually typed or copied from another source and simply be pasted into it. Similarly, a text in EditText can
2 min read
How to Add Image on EditText in Android?
In Android, An EditText is an overlay over a TextView that makes it editable using text by invoking a soft keyboard in run time. It is generally implemented to collect text data from the user. EditText is most commonly used in forms that require users to fill in details and for passing a search query. In this article, we will show you how you could
3 min read
Material Design EditText in Android with Example
EditText is one of the important UI elements. Edittext refers to the widget that displays an empty text field in which a user can enter the required text and this text is further used inside the application. In this article it has been discussed to implement the special type of text fields, those are called Material Design EditText. Have a look at
5 min read
Implement Form Validation (Error to EditText) in Android
Many of the already existing Android applications when it comes to the forms include user details. If the user enters the wrong information into the text fields or if the user leaves the text fields without filling them, there is a need to provide certain alert information to the TextFields which are unfilled and which contain the wrong information
6 min read
EditText in Android using Jetpack Compose
EditText is one of the most important widgets which is seen in most of the apps. This widget is generally used to get the data from users. Users can directly communicate with the app using this widget. This widget is used to get the data from the user in the form of numbers, text or any other text. In this article, we will take a look at the implem
8 min read
Flutter - Pixels Overflow Error while Launching Keyboard
There is a very common pixel overflow error in Flutter whenever there are too many widgets in a Column and they are not able to display completely when Keyboard is opened, then these kinds of Pixel Overflow errors are received. Example : The code for this UI is : C/C++ Code import 'package:flutter/material.dart'; import 'components.dart'; void main
2 min read
Dynamic EditText in Kotlin
EditText is used to get input from the user. EditText is commonly used in login or registration screens. we already learn how to create an EditText using layout. In this article, we will learn about how to create android EditText programmatically in kotlin. At first, we will create a new android application. Then, we will create an EditText dynamic
2 min read
Typing Animation Effect in Android
In this article, we are going to implement a very important feature related to TextView. This feature can be used to show important announcements or notifications in an App. Even we can add this feature to show important links for the user as this attracts the attention of the user. So here we are going to learn how to implement that feature. A sam
3 min read
Typing Indicator in Android
Typing Indicator has been seen on various apps like Instagram, Facebook Messenger, and many more. To build a chat app Typing Indicator will help to achieve a better user interface. One can also create a Typing Indicator in the app but for that, we have to design a layout for it, and also we have to take care of indicator animation and the color dif
2 min read
How to programmatically hide Android soft keyboard
In this article, we will learn about how to hide soft keyboard programmatically. The keyboard generally hides but there are certain instances when it does not hide. So for better user experience, the keyboard is hidden programmatically. Without using below approach, the default response of the app is shown below:- [video width="440" height="520" mp
2 min read
How to Invoke Keyboard Programmatically in Android?
Android System by defaults shows an on-screen keyboard when any UI element such as an Input Text element receives focus. For a better experience, a developer can explicitly specify the desired characteristics or any methods to invoke. Desired characteristics could be characters such as allowing only numerals, allowing only alphabets, or any other s
2 min read
How to Close or Hide Android Soft Keyboard with Kotlin?
Many times there is a need in which we have to close the android soft keyboard programmatically when the user has typed some text within the edit text. This type of functionality is generally required in four digits pins in which after users type 4 digit pin the keyboard will be closed programmatically within the android application. We will be cre
3 min read
How to Check the Visibility of Software Keyboard in Android?
In some cases, we should determine if the keyboard is displayed or not in a given activity. In this example, we can see how to verify the presence of a virtual keyboard on Android. With the release of Android 11 preview 2 and here, it appears that platform behavior for listening to keyboard changes is finally being implemented! This appears to use
2 min read
How to Disable Soft Keyboard Suggestions in Android?
In Android, we must have observed that in any application, if we are supposed to type in some input, we generally get suggestions for words and sentences from the keyboard. The keyboard helps us type incorrect words or sentences when we start typing. Similarly, it helps auto-correct if mistakenly type wrong spellings. This function is can be change
2 min read
Article Tags :