当前位置: 首页>>代码示例>>Java>>正文


Java MenuItemCompat.setOnActionExpandListener方法代码示例

本文整理汇总了Java中android.support.v4.view.MenuItemCompat.setOnActionExpandListener方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItemCompat.setOnActionExpandListener方法的具体用法?Java MenuItemCompat.setOnActionExpandListener怎么用?Java MenuItemCompat.setOnActionExpandListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.view.MenuItemCompat的用法示例。


在下文中一共展示了MenuItemCompat.setOnActionExpandListener方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the options menu from XML
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.options_menu, menu);

    SearchManager searchManager = (SearchManager)
            getSystemService(Context.SEARCH_SERVICE);
    MenuItem searchMenuItem = menu.findItem(R.id.menu_search);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();

    searchView.setSearchableInfo(searchManager.
            getSearchableInfo(getComponentName()));
    searchView.setOnQueryTextListener(this);
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);

    return true;
}
 
开发者ID:10clouds,项目名称:InifiniteRecyclerView,代码行数:19,代码来源:MainActivity.java

示例2: setupSearchView

import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
private void setupSearchView(MenuItem searchItem) {
    if (searchItem != null) {
        MenuItemCompat.setOnActionExpandListener(searchItem, this);
        SearchManager searchManager = (SearchManager) (getActivity()
                .getSystemService(Context.SEARCH_SERVICE));
        searchView = (SearchView) searchItem.getActionView();
        if (searchView != null) {
            searchView.setSearchableInfo(searchManager
                    .getSearchableInfo(getActivity().getComponentName()));
            searchView.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
            searchView.clearFocus();
            searchView.setOnQueryTextListener(this);
            setupSearchOptions(searchView);
        }
    }
}
 
开发者ID:graviton57,项目名称:TheNounProject,代码行数:17,代码来源:BaseSearchFragment.java

示例3: SearchViewItem

import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
public SearchViewItem(Activity activity, MenuItem searchMenuItem) {
    mSearchMenuItem = searchMenuItem;
    SearchManager searchManager = (SearchManager) activity.getSystemService(Context.SEARCH_SERVICE);
    SearchView searchView = (SearchView) searchMenuItem.getActionView();
    if (searchView == null) {
        return;
    }
    searchView.setSearchableInfo(searchManager.getSearchableInfo(activity.getComponentName()));
    MenuItemCompat.setOnActionExpandListener(searchMenuItem, this);
    searchView.setOnQueryTextListener(this);
}
 
开发者ID:hyb1996,项目名称:Auto.js,代码行数:12,代码来源:SearchViewItem.java

示例4: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_search, menu);
    MenuItem searchItem = menu.findItem(R.id.action_search);
    SearchView searchView =
            (SearchView) MenuItemCompat.getActionView(searchItem);
    searchView.setOnQueryTextListener(this);
    searchView.setInputType(InputType.TYPE_TEXT_FLAG_CAP_WORDS);
    searchView.setQuery(mPresenter.getSearchModels().get(0).getQuery(), false);
    if (isInputMode) {
        MenuItemCompat.expandActionView(searchItem);
    } else {
        MenuItemCompat.collapseActionView(searchItem);
    }
    MenuItemCompat.setOnActionExpandListener(searchItem, this);

    AutoCompleteTextView autoCompleteTextView = searchView
            .findViewById(android.support.v7.appcompat.R.id.search_src_text);
    autoCompleteTextView.setThreshold(0);
    autoCompleteTextView.setAdapter(new ArrayAdapter<>(this,
            R.layout.layout_item_simple_list, mPresenter.getSearchRecordList()));
    autoCompleteTextView.setDropDownBackgroundDrawable(new ColorDrawable(ViewUtils.getWindowBackground(getActivity())));
    autoCompleteTextView.setOnItemClickListener((parent, view, position, id) -> {
        onQueryTextSubmit(parent.getAdapter().getItem(position).toString());
    });

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:ThirtyDegreesRay,项目名称:OpenHub,代码行数:29,代码来源:SearchActivity.java


注:本文中的android.support.v4.view.MenuItemCompat.setOnActionExpandListener方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。