我必须开发一个 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)
我的代码有什么问题?为什么会出现这个错误?如何清除此错误?请给我解决方案。