Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide search/go button on soft keyboard when using search View?

I have implemented search view for my application. When i try to query i show results using Listview and want use to select one of them. If not available list will be empty. However people can click search icon/go in soft keyboard i want to hide that button.

I want user to select values from suggestions only and not search separately

How can we achieve this?

like image 829
virendrao Avatar asked Oct 19 '22 15:10

virendrao


1 Answers

Just prevent the user from using the button whenever the value is not in your list. To do that you can just handle the clicking of the enter button.

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_ENTER:
            if(isTextInList())
               return true;
            return false;
        default:
            return super.onKeyUp(keyCode, event);
    }
}

for more info: http://developer.android.com/training/keyboard-input/commands.html#SingleKey

like image 171
lucianohgo Avatar answered Oct 31 '22 15:10

lucianohgo