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


Java MenuItemCompat类代码示例

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


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

示例1: restoreActionViewStates

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
public void restoreActionViewStates(Bundle states) {
    if (states != null) {
        SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
        int itemCount = size();
        for (int i = 0; i < itemCount; i++) {
            MenuItem item = getItem(i);
            View v = MenuItemCompat.getActionView(item);
            if (!(v == null || v.getId() == -1)) {
                v.restoreHierarchyState(viewStates);
            }
            if (item.hasSubMenu()) {
                ((SubMenuBuilder) item.getSubMenu()).restoreActionViewStates(states);
            }
        }
        int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
        if (expandedId > 0) {
            MenuItem itemToExpand = findItem(expandedId);
            if (itemToExpand != null) {
                MenuItemCompat.expandActionView(itemToExpand);
            }
        }
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:24,代码来源:MenuBuilder.java

示例2: 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

示例3: 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

示例4: onOptionsItemSelected

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();


    // Fetch and store ShareActionProvider
    mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    //noinspection SimplifiableIfStatement
    if (id == R.id.action_settings) {
        startActivity(new Intent(App.getAppContext(),Settings.class));
        return true;
    }else  if (id == R.id.action_favorite) {
       favourite(post);
    }else  if (id == R.id.action_share) {
        shareTextUrl();
    }
    return super.onOptionsItemSelected(item);
}
 
开发者ID:jamesddube,项目名称:LaravelNewsApp,代码行数:23,代码来源:PostActivity.java

示例5: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    MenuInflater inflater = getMenuInflater();
    inflater.inflate(R.menu.share, menu);

    MenuItem item = menu.findItem(R.id.action_share);
    ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat.getActionProvider(item);

    Intent send = new Intent();
    send.setAction(Intent.ACTION_SEND);
    send.putExtra(Intent.EXTRA_TEXT, text.toString());
    send.setType("text/plain");
    if(shareAction != null) {
        shareAction.setShareIntent(send);
    }

    return super.onCreateOptionsMenu(menu);
}
 
开发者ID:IMSmobile,项目名称:Fahrplan,代码行数:19,代码来源:ConnectionActivity.java

示例6: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.ride_menu, menu);

    // store action provider
    shareMenuItem = menu.findItem(R.id.menu_item_share);
    shareMenuItem.setVisible(false);
    shareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);

    // Create share intent
    shareFileIntent = new Intent();
    shareFileIntent.setAction(Intent.ACTION_SEND);
    shareFileIntent.setType("text/csv");
    shareFileIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
    setShareIntent(shareFileIntent);

    return true;
}
 
开发者ID:ponewheel,项目名称:android-ponewheel,代码行数:19,代码来源:RideDetailActivity.java

示例7: 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.poem_toolbar, menu);

    favoriteItem = menu.findItem(R.id.action_addToFavorites);
    if (presenter.isFavorite()){
        favoriteItem.setIcon(R.drawable.ic_star_full);
    }

    MenuItem item = menu.findItem(R.id.action_share);

    ShareActionProvider mShareActionProvider =
            (ShareActionProvider) MenuItemCompat.getActionProvider(item);
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, presenter.getPoemContentString());
    mShareActionProvider.setShareIntent(shareIntent);
    return true;
}
 
开发者ID:PaulKlinger,项目名称:Sprog-App,代码行数:21,代码来源:PoemActivity.java

示例8: onPrepareOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {

  boolean res = super.onPrepareOptionsMenu(menu);

  MenuItem searchItem = menu.findItem(R.id.action_search);
  SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem);

  searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
    @Override
    public boolean onQueryTextSubmit(String query) {
      getWebViewCoordinator().onQueryByText(query);
      return true;
    }

    @Override
    public boolean onQueryTextChange(String newText) {
      return false;
    }
  });

  return res;
}
 
开发者ID:azmedien,项目名称:kolibri-android,代码行数:24,代码来源:PrototypeActivity.java

示例9: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main_menu, menu);
    MenuItem search = menu.findItem(R.id.search);
    SearchView searchView = (SearchView) MenuItemCompat.getActionView(search);
    searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
        @Override public boolean onQueryTextSubmit(String query) {
            getSupportActionBar().setSubtitle("found: "+mAdapter.getItemCount());
            return true;
        }
        @Override public boolean onQueryTextChange(String newText) {
            if (mAdapter != null) {
                mAdapter.getFilter().filter(newText);
            }
            return true;
        }
    });
    menu.findItem(R.id.action_settings).setIntent(new Intent(this,SettingsActivity.class));
    return true;
}
 
开发者ID:AlexeyZatsepin,项目名称:CP-Tester,代码行数:21,代码来源:MainActivity.java

示例10: fillApplicationList

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
private void fillApplicationList() {
    // Get recycler view
    final RecyclerView rvApplication = (RecyclerView) findViewById(R.id.rvApplication);
    rvApplication.setHasFixedSize(true);
    rvApplication.setLayoutManager(new LinearLayoutManager(this));

    // Get/set application list
    new AsyncTask<Object, Object, List<Rule>>() {
        @Override
        protected List<Rule> doInBackground(Object... arg) {
            return Rule.getRules(ActivityMain.this);
        }

        @Override
        protected void onPostExecute(List<Rule> result) {
            if (running) {
                if (searchItem != null)
                    MenuItemCompat.collapseActionView(searchItem);
                adapter = new RuleAdapter(result, ActivityMain.this);
                rvApplication.setAdapter(adapter);
            }
        }
    }.execute();
}
 
开发者ID:shivam141296,项目名称:Android-Firewall,代码行数:25,代码来源:ActivityMain.java

示例11: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.latest_menu, menu);
    getMenuInflater().inflate(R.menu.filter_menu, menu);

    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,代码行数:24,代码来源:LatestActivity.java

示例12: 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

示例13: onCreateOptionsMenu

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    // Inflate the menu and configure the media router action provider.
    getMenuInflater().inflate(R.menu.media_route_menu_item, menu);

    // Attach the MediaRouteSelector to the menu item
    MenuItem mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
    MediaRouteActionProvider mediaRouteActionProvider =
            (MediaRouteActionProvider)MenuItemCompat.getActionProvider(
                    mediaRouteMenuItem);
    // Attach the MediaRouteSelector that you built in onCreate()
    mediaRouteActionProvider.setRouteSelector(mSelector);

    // Return true to show the menu.
    return true;
}
 
开发者ID:tgbMedia,项目名称:Android-app,代码行数:19,代码来源:VideoPlayerActivity.java

示例14: 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) {
            Intent intent = new Intent("Msg_KeyWord");
            intent.putExtra("keyWord", query);
            sendBroadcast(intent);
            return true;
        }

        @Override
        public boolean onQueryTextChange(String newText) {

            return false;
        }
    });
    return true;
}
 
开发者ID:liuyongfeng90,项目名称:JKCloud,代码行数:25,代码来源:SystemReportActivity.java

示例15: getFocus

import android.support.v4.view.MenuItemCompat; //导入依赖的package包/类
private void getFocus() {
    getView().setFocusableInTouchMode(true);
    getView().requestFocus();
    getView().setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_UP && keyCode == KeyEvent.KEYCODE_BACK) {
                if (MenuItemCompat.isActionViewExpanded(search)) {
                    MenuItemCompat.collapseActionView(search);
                    return true;
                } else
                    return false;
            }
            return false;
        }
    });
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:18,代码来源:BusFragment.java


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