當前位置: 首頁>>代碼示例>>Java>>正文


Java SearchView.findViewById方法代碼示例

本文整理匯總了Java中android.widget.SearchView.findViewById方法的典型用法代碼示例。如果您正苦於以下問題:Java SearchView.findViewById方法的具體用法?Java SearchView.findViewById怎麽用?Java SearchView.findViewById使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.SearchView的用法示例。


在下文中一共展示了SearchView.findViewById方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
	super.onCreateOptionsMenu(menu);
	getMenuInflater().inflate(R.menu.main_menu, menu);
	this.menu = menu;

	SearchView addTag = (SearchView) menu.findItem(R.id.addTag).getActionView();
	addTag.setQueryHint("myjson id ( ex: 26dyf )");

	addTag.setOnQueryTextListener(new SearchView.OnQueryTextListener() {

		@Override
		public boolean onQueryTextSubmit(String query) {
			getTags(query);
			return false;
		}

		@Override
		public boolean onQueryTextChange(String newText) {
			return false;
		}
	});

	// Clean magnifier
	int searchCloseButtonId = addTag.getContext().getResources().getIdentifier("android:id/search_mag_icon", null, null);
	ImageView magIcon = (ImageView) addTag.findViewById(searchCloseButtonId);
	magIcon.setLayoutParams(new LinearLayout.LayoutParams(0, 0));
	magIcon.setVisibility(View.INVISIBLE);

	return true;
}
 
開發者ID:sambatech,項目名稱:player_sdk_android_sample_app,代碼行數:32,代碼來源:MainActivity.java

示例2: setBackground

import android.widget.SearchView; //導入方法依賴的package包/類
/**
 * Override the default background with a theme version.
 */
public static SearchView setBackground(SearchView view, @DrawableRes int drawableId) {
    int id = view.getResources().getIdentifier("android:id/search_plate", null, null);
    if (id > 0) {
        View search = view.findViewById(id);
        if (search != null) {
            search.setBackgroundResource(drawableId);
        }
    }
    return view;
}
 
開發者ID:pushbit,項目名稱:sprockets-android,代碼行數:14,代碼來源:SearchViews.java

示例3: customActionBarSearchViewTextColor

import android.widget.SearchView; //導入方法依賴的package包/類
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);

}
 
開發者ID:lookwhatlook,項目名稱:WeiboWeiBaTong,代碼行數:7,代碼來源:ThemeUtility.java

示例4: customActionBarSearchViewTextColor

import android.widget.SearchView; //導入方法依賴的package包/類
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);
}
 
開發者ID:jas0nchen,項目名稱:X.Ray,代碼行數:7,代碼來源:ThemeUtility.java

示例5: customActionBarSearchViewTextColor

import android.widget.SearchView; //導入方法依賴的package包/類
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);

}
 
開發者ID:andforce,項目名稱:iBeebo,代碼行數:7,代碼來源:ThemeUtility.java

示例6: onCreateOptionsMenu

import android.widget.SearchView; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.search, menu);

    // Get the SearchView
    MenuItem item = menu.findItem(R.id.action_search);
    Assert.assertNotNull(getSupportActionBar());
    final SearchView searchView = new SearchView(this);
    final int textViewID = searchView.getContext().getResources()
            .getIdentifier("android:id/search_src_text", null, null);
    final AutoCompleteTextView searchTextView =
            (AutoCompleteTextView) searchView.findViewById(textViewID);
    try {
        // Set the cursor to the same color as the text
        Field cursorDrawable = TextView.class.getDeclaredField("mCursorDrawableRes");
        cursorDrawable.setAccessible(true);
        cursorDrawable.set(searchTextView, 0);
    } catch (Exception e) {
        Timber.e(e, "Cannot change color of cursor");
    }

    // Set up the query listener
    MenuItemCompat.setActionView(item, searchView);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override
        public boolean onQueryTextSubmit(String query) {
            searchString = query;
            filterBySearchString();
            return false;
        }

        @Override
        public boolean onQueryTextChange(String newText) {
            searchString = newText;
            filterBySearchString();
            return false;
        }
    });

    //Reset the search view
    searchView.setOnCloseListener(new SearchView.OnCloseListener() {
        @Override
        public boolean onClose() {
            searchString = "";
            filterBySearchString();
            return false;
        }
    });

    return true;
}
 
開發者ID:jguerinet,項目名稱:MyMartlet,代碼行數:52,代碼來源:MapActivity.java


注:本文中的android.widget.SearchView.findViewById方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。