Check if Android device has search hardware button

前端 未结 2 340
轮回少年
轮回少年 2021-01-11 23:18

I need help figuring out how to check if a device is equipped with the search hardware button or not. Is this possible?

EDIT: I\'m talking about finding out if the d

2条回答
  •  醉梦人生
    2021-01-12 00:09

    Better way you can do usign two ways

    1. put the search button and call to onSearchRequested();

    2. Second way on click the editText put android:imeOptions="actionSearch" so you need to
      check for key

      searchBox.setOnEditorActionListener(new OnEditorActionListener()
      {
          public boolean onEditorAction(TextView textView, int id,KeyEvent event) 
          {
          if (id == EditorInfo.IME_ACTION_SEARCH)
              {
                   //do what ever you want
              }
          return true;
          }
      });
      

    Hope this will help you.

提交回复
热议问题