我必须开发一个android应用程序,我使用的片段和youtube播放器API。我已经添加了youtubefailurerrecoveryactivity,我得到下面的错误:
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)
我的代码有什么问题?为什么会出现这个错误?如何清除此错误?
Java中不能同时继承两个类!
使用YouTubePlayerSupportFragment,如果你只是在一个支持4.0 .app. fragment播放YouTube视频。这允许你使用FragmentActivity,而不是YouTubeBaseActivity。
如果你有任何疑问,请说:
从这些链接得到答案