本文整理匯總了Java中android.support.v4.view.MenuItemCompat.getActionView方法的典型用法代碼示例。如果您正苦於以下問題:Java MenuItemCompat.getActionView方法的具體用法?Java MenuItemCompat.getActionView怎麽用?Java MenuItemCompat.getActionView使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.v4.view.MenuItemCompat
的用法示例。
在下文中一共展示了MenuItemCompat.getActionView方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
/*簡單查詢*/
final MenuItem item = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
paraMap.put("keyWord", query);
showLoading();
refresh = true;
presenter.getData(1, SIZE, paraMap);
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
示例2: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
final MenuItem item = menu.findItem(R.id.action_search);
SearchView mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setIconifiedByDefault(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
if (shouldShowFAQ)
((Searchable) currentFragment).setSearchText(newText);
return true;
}
});
return super.onCreateOptionsMenu(menu);
}
示例3: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.project_menu, menu);
sortByName = menu.findItem(R.id.menu_sort_by_name);
sortByTimeSpent = menu.findItem(R.id.menu_sort_by_time);
sortByName.setChecked(isSortedByName);
sortByTimeSpent.setChecked(isSortedByName);
sortData();
final MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setQueryHint(context.getString(R.string.search_hint));
searchView.setOnQueryTextListener(this);
}
示例4: initializeSearchView
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
private void initializeSearchView(Menu menu) {
final SearchView searchView = (SearchView) MenuItemCompat
.getActionView(menu.findItem(R.id.search));
SearchManager searchManager = (SearchManager) getSystemService(SEARCH_SERVICE);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
return false;
}
@Override
public boolean onQueryTextChange(String newText) {
getPresenter().search(newText);
return false;
}
});
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
}
示例5: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.filter_menu, menu); // inflate the filter
MenuItem searchViewItem = menu.findItem(R.id.filter_keyword);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchViewItem);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
filter.filter("K:" + searchView.getQuery());
searchView.clearFocus();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
filter.filter("K:" + searchView.getQuery());
return false;
}
});
return true;
}
示例6: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_discovery, menu);
final MenuItem item = menu.findItem(R.id.action_search);
SearchManager searchManager = (SearchManager) DiscoveryActivity.this.getSystemService(Context.SEARCH_SERVICE);
SearchView searchView = (SearchView) MenuItemCompat.getActionView(item);
ComponentName componentName = new ComponentName(this, SearchableActivity.class);
searchView.setSearchableInfo(searchManager.getSearchableInfo(componentName));
return true;
}
示例7: updateAdapter
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
private void updateAdapter() {
if (adapter != null) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
boolean udp = prefs.getBoolean("proto_udp", true);
boolean tcp = prefs.getBoolean("proto_tcp", true);
boolean other = prefs.getBoolean("proto_other", true);
boolean allowed = prefs.getBoolean("traffic_allowed", true);
boolean blocked = prefs.getBoolean("traffic_blocked", true);
adapter.changeCursor(DatabaseHelper.getInstance(this).getLog(udp, tcp, other, allowed, blocked));
if (menuSearch != null && menuSearch.isActionViewExpanded()) {
SearchView searchView = (SearchView) MenuItemCompat.getActionView(menuSearch);
adapter.getFilter().filter(searchView.getQuery().toString());
}
}
}
示例8: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
Log.i(TAG, "Creating menu...");
inflater.inflate(R.menu.main_menu, menu);
final MenuItem searchItem = menu.findItem(R.id.action_search);
final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setOnQueryTextListener(this);
}
示例9: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search_view, menu);
MenuItem searchItem = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(searchItem);
mSearchView.setQueryHint("輸入歌曲名查找");
mSearchView.onActionViewExpanded();// 當展開無輸入內容的時候,沒有關閉的圖標
mSearchView.setIconified(true);//設置searchView處於展開狀態
// searchView.setSubmitButtonEnabled(true);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//提交按鈕的點擊事件
Toast.makeText(SearchViewActivity.this, query, Toast.LENGTH_SHORT).show();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
//當輸入框內容改變的時候回調
// Log.i(TAG,"內容: " + newText);
quertMusic(newText);
return true;
}
});
mSearchAutoComplete = (SearchView.SearchAutoComplete) mSearchView.findViewById(R.id.search_src_text);
//設置輸入框內容文字和提示文字的顏色
mSearchAutoComplete.setHintTextColor(getResources().getColor(android.R.color.white));
mSearchAutoComplete.setTextColor(getResources().getColor(android.R.color.white));
return super.onCreateOptionsMenu(menu);
}
示例10: onCreateView
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View gridFrag = inflater.inflate(R.layout.fragment_grid, container, false);
ButterKnife.bind(this, gridFrag);
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
MenuItem item = toolbar.getMenu().findItem(R.id.spinner);
mSpinner = (Spinner) MenuItemCompat.getActionView(item);
return gridFrag;
}
示例11: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.song_sort_by, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.song_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search song");
menu.findItem(R.id.grid_view).setVisible(false);
menu.findItem(R.id.default_folder).setVisible(true);
}
示例12: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.album_view_menu, menu);
searchView = (SearchView) MenuItemCompat.getActionView(menu.findItem(R.id.album_search));
searchView.setOnQueryTextListener(this);
searchView.setQueryHint("Search album");
if (Extras.getInstance().albumView()) {
menu.findItem(R.id.grid_view).setVisible(false);
} else {
menu.findItem(R.id.grid_view).setVisible(true);
}
}
示例13: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(final Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
/*簡單查詢*/
final MenuItem item = menu.findItem(R.id.action_search);
mSearchView = (SearchView) MenuItemCompat.getActionView(item);
mSearchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
List<Company> list = DataSupport
.where("CompanyShortName LIKE ?", "%" + query + "%")
.find(Company.class);
if (CompanyList != null) {
CompanyList.clear();
}
if (list.size() > 0) {
hasMore = true;
CompanyList.addAll(list);
} else {
Toast.makeText(CompanyListActivity.this, "沒有找到匹配的公司!", Toast.LENGTH_SHORT).show();
}
Adapter.notifyDataSetChanged();
return true;
}
@Override
public boolean onQueryTextChange(String newText) {
return false;
}
});
return true;
}
示例14: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main, menu);
searchItem = menu.findItem(R.id.search);
SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE);
searchView = (SearchView) MenuItemCompat.getActionView(searchItem);
searchView.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName()));
searchView.setOnQueryTextListener(this);
return true;
}
示例15: onCreateView
import android.support.v4.view.MenuItemCompat; //導入方法依賴的package包/類
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View gridFrag = inflater.inflate(R.layout.fragment_dash, container, false);
ButterKnife.bind(this, gridFrag);
Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.toolbar);
MenuItem item = toolbar.getMenu().findItem(R.id.spinner);
if (item != null)
mSpinner = (Spinner) MenuItemCompat.getActionView(item);
return gridFrag;
}