Reputation: 45
I using video view for youtube videos but OnCreateOptionsMenu
not running. How to use not used youtubeplayerfragment? Is the YouTubeBaseActivity inside support use ?
This videoactivity.class
public class videoactivity extends YouTubeBaseActivity{
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean loadAgain) {
if (!loadAgain) {
youTubePlayer.cueVideo(ID_VIDEO);
}
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
}
}
and OnCreateOptionsMenu
method:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.video_menu, menu);
return super.onCreateOptionsMenu(menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
super.onOptionsItemSelected(item);
this.finish();
goBackWithAnimation();
break;
case R.id.share_button:
showShareOptions();
break;
}
return true;
}
but not running. How to use?
Upvotes: 1
Views: 229
Reputation: 6078
I tried in my class which extends YouTubeBaseActivity
, and it works.
You need to set the style/theme that has an ActionBar
or Toolbar
which contains menu, and it will call the method.
You can take look at project here, clone it, and try yourself. Click Simple PlayerView
and it will pop up ActionBar
with menu which call the method.
Basically, I add the two method here and set the style/theme for the activity here.
And it called the menu method as follows:
Upvotes: 1