List of usage examples for android.widget SearchView setFocusable
public void setFocusable(boolean focusable)
From source file:com.jpuyo.barcelonaplaces.app.ui.activity.main.PlacesListFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.placeslist_fragment, container, false); mApp = (BarcelonaPlacesApp) getActivity().getApplicationContext(); mPlacesAdapter = new PlacesCursorCardAdapter(getActivity(), this); mPlacesAdapter.setPlaceDetailManager(mApp.getPlacesDetailManager()); CardListView mListView = (CardListView) rootView.findViewById(R.id.cardlistview_placeslist_fragment); mListView.setAdapter(mPlacesAdapter); SearchView mSearchView = (SearchView) rootView.findViewById(R.id.searchview_place); mSearchView.setFocusable(true); mSearchView.setIconifiedByDefault(false); mSearchView.setOnQueryTextListener(this); return rootView; }
From source file:edu.ucsb.cs.cs185.inspirante.searchbyranking.SearchByRankingFragment.java
@Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_search_by_ranking, container, false); final SearchView searchView = (SearchView) rootView.findViewById(R.id.search_by_ranking_search_view); int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); EditText searchEditText = (EditText) searchView.findViewById(id); searchEditText.setTextColor(Color.GRAY); searchEditText.setHintTextColor(Color.GRAY); searchView.setOnQueryTextListener(searchViewListener); searchView.setMaxWidth(Integer.MAX_VALUE); searchView.setOnClickListener(new View.OnClickListener() { @Override/* w ww . j a v a2s . c o m*/ public void onClick(View view) { searchView.setFocusable(true); searchView.setIconified(false); searchView.requestFocusFromTouch(); } }); mInspireRecyclerView = (RecyclerView) rootView.findViewById(R.id.search_rv); mInspireRecyclerView.setHasFixedSize(true); mInspireRecyclerView.setNestedScrollingEnabled(false); frequentTags = ItemCards.getInstance(getContext()).getFrequentTags(); mInspireAdapter = new RankByTagAdapter(getContext(), this, frequentTags); mInspireAdapter.setHasStableIds(true); mLayoutManager = new LinearLayoutManager(getContext()); mLayoutManager.setItemPrefetchEnabled(true); mInspireRecyclerView.setLayoutManager(mLayoutManager); mInspireAdapter.setOnItemClickListener(new RankByTagAdapter.OnRecyclerViewItemClickListener() { @Override public void onItemClick(View view, int position) { TextView tv = (TextView) view; Intent intent = new Intent(getActivity(), TagAndImagesActivity.class); intent.putExtra("TAG", tv.getText()); startActivity(intent); } }); ItemCards itemCards = ItemCards.getInstance(getContext()); itemCards.setAdapter(mInspireAdapter); mInspireRecyclerView.setAdapter(mInspireAdapter); mInspireAdapter.notifyDataSetChanged(); // Set Tag recycler view mTagRecyclerView = (RecyclerView) rootView.findViewById(R.id.search_tags_rv); mTagRecyclerView.setHasFixedSize(true); mTagRecyclerView.setNestedScrollingEnabled(false); mTagsAdapter = new TagsAdapter(getContext(), frequentTags); mTagsAdapter.setHasStableIds(true); RecyclerView.LayoutManager tagsLayoutManager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); tagsLayoutManager.setItemPrefetchEnabled(true); mTagRecyclerView.setLayoutManager(tagsLayoutManager); mTagsAdapter.setOnItemClickListener(new TagsAdapter.OnRecyclerViewItemClickListener() { @Override public void onItemClick(View view, int position) { String tag = mTagsAdapter.getTag(position); searchViewListener.onQueryTextChange(tag); //searchView.setFocus searchView.setQuery(tag, true); searchView.setIconified(false); searchView.clearFocus(); mLayoutManager.scrollToPosition(0); } }); mTagRecyclerView.setAdapter(mTagsAdapter); mTagsAdapter.notifyDataSetChanged(); return rootView; }