How to set edittext to show search button or enter button on keyboard?

Use the code to edit EditText attribute

<EditText android:imeOptions="actionSearch" />

Then do this in your java code:

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            performSearch();
            return true;
        }
        return false;
    }
});

In your layout set input method to option to Search

 <EditText 
  android:imeOptions="actionSearch"
  android:inputType="text"/>

and in java code use

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
    @Override
    public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
        if (actionId == EditorInfo.IME_ACTION_SEARCH) {
            performSearch();
            return true;
        }
        return false;
    }
});