打开搜索时自动获取焦点

pull/951/head
gedoor 4 years ago
parent b7ef90eb22
commit 2cd223637d
  1. 4
      app/src/main/java/io/legado/app/ui/book/search/SearchActivity.kt

@ -6,6 +6,7 @@ import android.view.Menu
import android.view.MenuItem import android.view.MenuItem
import android.view.View.GONE import android.view.View.GONE
import android.view.View.VISIBLE import android.view.View.VISIBLE
import android.widget.TextView
import androidx.activity.viewModels import androidx.activity.viewModels
import androidx.appcompat.widget.SearchView import androidx.appcompat.widget.SearchView
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
@ -214,7 +215,8 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
intent?.getStringExtra("key")?.let { intent?.getStringExtra("key")?.let {
searchView.setQuery(it, true) searchView.setQuery(it, true)
} ?: let { } ?: let {
searchView.requestFocus() searchView.findViewById<TextView>(androidx.appcompat.R.id.search_src_text)
.requestFocus()
} }
} }

Loading…
Cancel
Save