下面列出了androidx.recyclerview.widget.RecyclerView#requestFocus ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void onResume() {
super.onResume();
if (getActivity() == null) {
return;
}
if (current_nodes_type == entryNodes) {
getActivity().setTitle(R.string.pref_tor_entry_nodes);
} else if (current_nodes_type == excludeNodes) {
getActivity().setTitle(R.string.pref_tor_exclude_nodes);
} else if (current_nodes_type == exitNodes) {
getActivity().setTitle(R.string.pref_tor_exit_nodes);
} else if (current_nodes_type == excludeExitNodes) {
getActivity().setTitle(R.string.pref_tor_exclude_exit_nodes);
}
CheckBox chbTorCountriesSelectorAll = getActivity().findViewById(R.id.chbTorCountriesSelectorAll);
chbTorCountriesSelectorAll.setOnCheckedChangeListener(this);
((SearchView) getActivity().findViewById(R.id.searhTorCountry)).setOnQueryTextListener(this);
RecyclerView rvSelectCountries = getActivity().findViewById(R.id.rvSelectCountries);
RecyclerView.LayoutManager mLayoutManager = new LinearLayoutManager(getActivity());
rvSelectCountries.setLayoutManager(mLayoutManager);
rvSelectCountries.requestFocus();
rvAdapter = new CountriesAdapter();
rvSelectCountries.setAdapter(rvAdapter);
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
if (recyclerView.getScrollState() != RecyclerView.SCROLL_STATE_SETTLING) {
recyclerView.requestFocus();
}
}