當前位置: 首頁>>代碼示例>>Java>>正文


Java MenuItemCompat.getActionProvider方法代碼示例

本文整理匯總了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);
}
 
開發者ID:jamesddube,項目名稱:LaravelNewsApp,代碼行數:23,代碼來源:PostActivity.java

示例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);
}
 
開發者ID:IMSmobile,項目名稱:Fahrplan,代碼行數:19,代碼來源:ConnectionActivity.java

示例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;
}
 
開發者ID:ponewheel,項目名稱:android-ponewheel,代碼行數:19,代碼來源:RideDetailActivity.java

示例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;
}
 
開發者ID:PaulKlinger,項目名稱:Sprog-App,代碼行數:21,代碼來源:PoemActivity.java

示例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));
        }
    }
}
 
開發者ID:victoraldir,項目名稱:BuddyBook,代碼行數:20,代碼來源:DetailActivityFragment.java

示例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;
}
 
開發者ID:tgbMedia,項目名稱:Android-app,代碼行數:19,代碼來源:VideoPlayerActivity.java

示例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;
			}
		});
	}
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:27,代碼來源:StreamFragment.java

示例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);
        }
    }
 
開發者ID:victoraldir,項目名稱:BuddyBook,代碼行數:10,代碼來源:MainActivity.java

示例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());
}
 
開發者ID:twisstosin,項目名稱:UdacityBakingAndroid,代碼行數:9,代碼來源:RecipeDetailFragment.java

示例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;
}
 
開發者ID:BernhardWebstudio,項目名稱:ShadowTravelor,代碼行數:15,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:steveyangmoto,項目名稱:file_scanner,代碼行數:9,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:13,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:SebastianRask,項目名稱:Pocket-Plays-for-Twitch,代碼行數:20,代碼來源:BaseCastManager.java

示例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;
}
 
開發者ID:Orange-OpenSource,項目名稱:OCast-Java,代碼行數:14,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:ujjwalagrawal17,項目名稱:CodeCompilerApp,代碼行數:65,代碼來源:MainActivity.java


注:本文中的android.support.v4.view.MenuItemCompat.getActionProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。