我必须开发一个Android应用程序,我正在使用片段和youtube播放器API。我添加了YouTubeFailureRecoveryActivity,我收到错误:
Syntax error, insert "ClassBody" to complete ClassDeclaration
我使用过这段代码:
public class SubCate extends Fragment,YouTubeFailureRecoveryActivity
{
TextView lblName;
String _Title,_Video;
WebView fullcontent;
YouTubePlayerView youTubeView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.subcate,
container, false);
lblName = (TextView) view.findViewById(R.id.title);
fullcontent = (WebView) view.findViewById(R.id.fullcontent);
youTubeView = (YouTubePlayerView) view.findViewById(R.id.youtube_view);
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, getActivity());
Bundle bundle = getArguments();
return view;
}
public void updateDetail(String articletitle,String articlefullcontent,String articlevideo) {
_Title = articletitle.substring(1);
lblName.setText(_Title);
_Video = articlevideo.substring(1);
}
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored) {
if (!wasRestored) {
player.cueVideo(_Video);
}
}
protected YouTubePlayer.Provider getYouTubePlayerProvider() {
return youTubeView;
}
}
修改
我已从我的扩展课程中删除了YouTubeFailureRecoveryActivity课程。
现在我在这一行收到错误:
youTubeView.initialize(DeveloperKey.DEVELOPER_KEY, getActivity());
错误是:
The method initialize(String, YouTubePlayer.OnInitializedListener) in the type YouTubePlayerView is not applicable for the arguments (String, Activity)
我的代码有什么问题?为什么我得到这个错误?如何清除此错误? 请给我解决方案。
答案 0 :(得分:3)
你不能从Java继承两个类!
答案 1 :(得分:0)
如果您只在一个support.v4.app.Fragment中播放YouTube视频,请使用YouTubePlayerSupportFragment。这允许您使用FragmentActivity而不是YouTubeBaseActivity。
如果您有任何疑问,请: