Reputation: 3533
I use custom search screen in my tv app, and my problem is that I can't set the focus on SearchBar
view when starting the fragment. I've tried the following approaches :
mSearchBar.setFocusable(true);
mSearchBar.requestFocus();
also tried in xml
<android.support.v17.leanback.widget.SearchBar
android:id="@+id/search_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clipChildren="false"
android:focusable="true">
<requestFocus />
</android.support.v17.leanback.widget.SearchBar>
and this
mSearchBar.setSearchQuery("");
nothing of above set the focus for SearchBar
Upvotes: 2
Views: 1517
Reputation: 479
If you are talking about Leanback's SearchFragment, then try this in your search activity:
searchEditText = (SearchEditText) findViewById(R.id.lb_search_text_editor);
searchEditText.requestFocus();
Upvotes: 1