我必須開發一個Android應用程序,我使用的是片段和YouTube播放器API。我已經加入YouTubeFailureRecoveryActivity,我波紋管得到的錯誤:使用Youtube播放器與android片段
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)
什麼是錯在我的代碼?爲什麼我得到這個錯誤?我怎樣才能清除這個錯誤? 請給我這個解決方案。