當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。