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


Java MenuItemCompat.getActionView方法代码示例

本文整理汇总了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;
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:26,代码来源:OpportunityListActivity.java

示例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);
}
 
开发者ID:w568w,项目名称:fuckView,代码行数:22,代码来源:MainActivity.java

示例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);
}
 
开发者ID:Protino,项目名称:CodeWatch,代码行数:19,代码来源:ProjectsFragment.java

示例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()));
}
 
开发者ID:Laaidback,项目名称:A.scribe,代码行数:18,代码来源:MainActivity.java

示例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;
}
 
开发者ID:CMPUT301W17T08,项目名称:Moodr,代码行数:27,代码来源:Profile.java

示例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;
}
 
开发者ID:auv1107,项目名称:TextEmoji,代码行数:14,代码来源:DiscoveryActivity.java

示例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());
        }
    }
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:16,代码来源:ActivityLog.java

示例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);


}
 
开发者ID:DecentralizedAmateurPagingNetwork,项目名称:DAPNETApp,代码行数:12,代码来源:CallFragment.java

示例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);
    }
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:39,代码来源:SearchViewActivity.java

示例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;
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:12,代码来源:GridPagerFragment.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:11,代码来源:FolderFragment.java

示例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);
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:14,代码来源:AlbumListFragment.java

示例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;
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:35,代码来源:CompanyListActivity.java

示例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;
}
 
开发者ID:dkanada,项目名称:OpenAPK,代码行数:15,代码来源:MainActivity.java

示例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;
}
 
开发者ID:riteshakya037,项目名称:Android-Scrapper,代码行数:13,代码来源:DashFragment.java


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