本文整理汇总了Java中android.support.v4.view.MenuItemCompat.getActionProvider方法的典型用法代码示例。如果您正苦于以下问题:Java MenuItemCompat.getActionProvider方法的具体用法?Java MenuItemCompat.getActionProvider怎么用?Java MenuItemCompat.getActionProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.view.MenuItemCompat
的用法示例。
在下文中一共展示了MenuItemCompat.getActionProvider方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: 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;
}
示例4: 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;
}
示例5: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (getActivity() instanceof MainActivity) {
((MainActivity) getActivity()).setIntentShareMenu(createShareBookIntent(mBookSelected));
} else {
inflater.inflate(R.menu.menu_detail, menu);
MenuItem menushareItem = menu.findItem(R.id.action_share);
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menushareItem);
if (mBookSelected != null) {
menushareItem.setVisible(true);
mShareActionProvider.setShareIntent(createShareBookIntent(mBookSelected));
}
}
}
示例6: 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;
}
示例7: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
if (!embedded) {
// Only add chromecast btn for live streams
if (vodId == null) {
mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
MenuItem routeItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteButton = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(routeItem);
mediaRouteButton.setDialogFactory(mMediaRouteDialogFactory);
}
optionsMenuItem = menu.findItem(R.id.menu_item_options);
optionsMenuItem.setVisible(false);
optionsMenuItem.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem menuItem) {
if (mQualityButton != null) {
mQualityButton.performClick();
}
return true;
}
});
}
}
示例8: setIntentShareMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
public void setIntentShareMenu(Intent intent){
if(mToolbar2 != null) {
MenuItem menushareItem = mToolbar2.getMenu().findItem(R.id.action_share);
ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(menushareItem);
menushareItem.setVisible(true);
mShareActionProvider.setShareIntent(intent);
}
}
示例9: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {
super.onCreateOptionsMenu(menu, menuInflater);
menuInflater.inflate(R.menu.recipe_detail_menu, menu);
MenuItem item = menu.findItem(R.id.menu_item_detail_share);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
setShareIntent(createShareIntent());
}
示例10: 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_main, menu);
// Locate MenuItem with ShareActionProvider
MenuItem item = menu.findItem(R.id.action_share);
// Fetch and store ShareActionProvider
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
// Return true to display menu
return true;
}
示例11: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main_menu, menu);
this.shareMenuItem = menu.findItem(R.id.menu_item_share);
shareMenuItem.setEnabled(false);
mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(shareMenuItem);
return true;
}
示例12: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_main_activity, menu);
mCastManager.addMediaRouterButton(menu, R.id.media_route_menu_item);
MenuItem routeItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider mediaRouteButton = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(routeItem);
mediaRouteButton.setDialogFactory(mMediaRouteDialogFactory);
return true;
}
示例13: addMediaRouterButton
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
/**
* Adds and wires up the Media Router cast button. It returns a reference to the Media Router
* menu item if the caller needs such reference. It is assumed that the enclosing
* {@link android.app.Activity} inherits (directly or indirectly) from
* {@link android.support.v7.app.AppCompatActivity}.
*
* @param menu Menu reference
* @param menuResourceId The resource id of the cast button in the xml menu descriptor file
*/
public final MenuItem addMediaRouterButton(Menu menu, int menuResourceId) {
MenuItem mediaRouteMenuItem = menu.findItem(menuResourceId);
MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)
MenuItemCompat.getActionProvider(mediaRouteMenuItem);
mediaRouteActionProvider.setRouteSelector(mMediaRouteSelector);
if (getMediaRouteDialogFactory() != null) {
mediaRouteActionProvider.setDialogFactory(getMediaRouteDialogFactory());
}
return mediaRouteMenuItem;
}
示例14: onCreateOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.main, menu);
mediaRouteMenuItem = menu.findItem(R.id.media_route_menu_item);
MediaRouteActionProvider actionProvider = (MediaRouteActionProvider) MenuItemCompat.getActionProvider(mediaRouteMenuItem);
MediaRouteSelector.Builder builder = new MediaRouteSelector.Builder().addControlCategory(OCastMediaRouteProvider.CATEGORY_OCAST);
MediaRouteSelector customSelector = builder.build();
actionProvider.setRouteSelector(customSelector);
return true;
}
示例15: onPrepareOptionsMenu
import android.support.v4.view.MenuItemCompat; //导入方法依赖的package包/类
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
if (fileOpened && searchResult != null) {
MenuItem imReplace = menu.findItem(R.id.im_replace);
MenuItem imReplaceAll = menu.findItem(R.id.im_replace_all);
MenuItem imPrev = menu.findItem(R.id.im_previous_item);
MenuItem imNext = menu.findItem(R.id.im_next_item);
if (imReplace != null)
imReplace.setVisible(searchResult.canReplaceSomething());
if (imReplaceAll != null)
imReplaceAll.setVisible(searchResult.canReplaceSomething());
if (imPrev != null)
imPrev.setVisible(searchResult.hasPrevious());
if (imNext != null)
imNext.setVisible(searchResult.hasNext());
} else if (fileOpened) {
MenuItem imSave = menu.findItem(R.id.im_save);
MenuItem imUndo = menu.findItem(R.id.im_undo);
MenuItem imRedo = menu.findItem(R.id.im_redo);
if (mEditor != null) {
if (imSave != null)
imSave.setVisible(mEditor.canSaveFile());
if (imUndo != null)
imUndo.setVisible(mEditor.getCanUndo());
if (imRedo != null)
imRedo.setVisible(mEditor.getCanRedo());
} else {
imSave.setVisible(false);
imUndo.setVisible(false);
imRedo.setVisible(false);
}
MenuItem imMarkdown = menu.findItem(R.id.im_view_markdown);
boolean isMarkdown = Arrays.asList(MimeTypes.MIME_MARKDOWN).contains(FilenameUtils.getExtension(greatUri.getFileName()));
if (imMarkdown != null)
imMarkdown.setVisible(isMarkdown);
MenuItem imShare = menu.findItem(R.id.im_share);
if (imMarkdown != null) {
ShareActionProvider shareAction = (ShareActionProvider) MenuItemCompat
.getActionProvider(imShare);
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.putExtra(Intent.EXTRA_STREAM, greatUri.getUri());
shareIntent.setType("text/plain");
shareAction.setShareIntent(shareIntent);
}
}
MenuItem imDonate = menu.findItem(R.id.im_donate);
if (imDonate != null)
if (ProCheckUtils.isPro(this, false))
imDonate.setVisible(false);
return true;
}