本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}