本文整理汇总了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;
}