Java Code Examples for android.widget.SearchView#findViewById()

The following examples show how to use android.widget.SearchView#findViewById() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AlarmListActivity.java    From boilr with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	// Inflate the menu; this adds items to the action bar if it is present.
	getMenuInflater().inflate(R.menu.alarm_list, menu);
	mSearchView = (SearchView) menu.findItem(R.id.action_search).getActionView();
	mSearchView.setOnQueryTextListener(queryListener);
	/*
	 * Hack to keep the search icon consistent between themes. Without this
	 * the icon for the light theme is smaller than the one on the dark
	 * theme. By just_user on Stack Overflow http://stackoverflow.com/questions/10445760/how-to-change-the-default-icon-on-the-searchview-to-be-use-in-the-action-bar-on/18360563#18360563
	 */
	int searchImgId = getResources().getIdentifier("android:id/search_button", null, null);
	ImageView view = (ImageView) mSearchView.findViewById(searchImgId);
	TypedArray ta = obtainStyledAttributes(attrs);
	view.setImageResource(ta.getResourceId(0, R.drawable.ic_action_remove_light));
	return super.onCreateOptionsMenu(menu);
}
 
Example 2
Source File: ManPageSearchFragment.java    From Man-Man with GNU General Public License v3.0 6 votes vote down vote up
@NonNull
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    cachedChapters = Utils.parseStringArray(getActivity(), R.array.man_page_chapters);

    // Inflate the layout for this fragment
    View root = inflater.inflate(R.layout.fragment_man_page_search, container, false);
    mSearchView = (SearchView) root.findViewById(R.id.query_edit);
    mSearchView.setOnQueryTextListener(new SearchQueryTextListener());
    mSearchImage = (ImageView) mSearchView.findViewById(Resources.getSystem().getIdentifier("search_mag_icon", "id", "android"));
    mSearchDefaultDrawable = mSearchImage.getDrawable();
    mSearchList = (ListView) root.findViewById(R.id.search_results_list);

    mUiHandler = new Handler();
    getLoaderManager().initLoader(MainPagerActivity.SEARCH_COMMAND_LOADER, null, mSearchCommandCallback);
    getLoaderManager().initLoader(MainPagerActivity.SEARCH_ONELINER_LOADER, null, mSearchOneLinerCallback);
    return root;
}
 
Example 3
Source File: MainActivity.java    From xunmi_android with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);
    searchView = (SearchView)menu.findItem(R.id.searchView).getActionView();
    int searchImgId = getResources().getIdentifier("android:id/search_button", null, null);
    ImageView v = (ImageView) searchView.findViewById(searchImgId);
    v.setImageResource(R.drawable.search); 
    searchView.setOnQueryTextListener(MainActivity.this);
    searchView.setSubmitButtonEnabled(true);
		
    searchView.setOnCloseListener(MainActivity.this);
    return true;
}
 
Example 4
Source File: ThemeUtility.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
public static void customActionBarSearchViewTextColor(SearchView searchView) {
    int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
    TextView textView = (TextView) searchView.findViewById(id);
    textView.setTextColor(Color.WHITE);

}
 
Example 5
Source File: ThemeUtility.java    From iBeebo with GNU General Public License v3.0 4 votes vote down vote up
public static void customActionBarSearchViewTextColor(SearchView searchView) {
    int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
    TextView textView = (TextView) searchView.findViewById(id);
    textView.setTextColor(Color.WHITE);

}