Столкнулся с вот такой проблемой, никак не могу ее решить, помогите, плизз:
public class Risunok_page11 extends Fragment implements YouTubePlayer.OnInitializedListener {
public void onInitializationSuccess(Provider provider, YouTubePlayer player,
boolean wasRestored) {
if (!wasRestored) {
player.cueVideo(VIDEO_ID);
}
}
public static final String API_KEY = "MyKey";
public static final String VIDEO_ID = "o7VVHhK9zf0";
private TextView text;
public Risunok_page11() {}
public final static String TAG = Risunok_page11.class.getSimpleName();
public static Risunok_page11 newInstance() {
return new Risunok_page11();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.risunok_page11_layout , container, false);
text=(TextView)rootView.findViewById(R.id.webtextview1);
ConnectivityManager cn =(ConnectivityManager)getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo nf=cn.getActiveNetworkInfo();
if(nf != null && nf.isConnected()==true )
{
YouTubePlayerFragment youTubePlayerFragment = (YouTubePlayerFragment) getActivity().getFragmentManager().findFragmentById(R.id.youtubeplayerfragment);
youTubePlayerFragment.initialize(API_KEY, this);
}
else
{
Toast.makeText(getActivity(), R.string.not_internet_please, Toast.LENGTH_LONG).show();
text.setTypeface(Typeface.createFromAsset(getActivity().getAssets(), "KShYJgLB.ttf"));
text.setText(R.string.not_internet);
}
return rootView;
}
public void onInitializationFailure(Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(getApplicationContext(),
"onInitializationFailure()",
Toast.LENGTH_LONG).show();
}
private Context getApplicationContext() {
// TODO Auto-generated method stub
return null;
}
}
В лайауте вот что:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<LinearLayout
android:id="@+id/LayoutHome1"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<fragment
android:id="@+id/youtubeplayerfragment"
android:layout_width="match_parent"
android:layout_weight="0.02"
class="com.google.android.youtube.player.YouTubePlayerFragment" />
<TextView
android:id="@+id/webtextview1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:gravity="center"
android:textSize="40sp"/>
</LinearLayout>
</LinearLayout>
Ошибка по стектрейсу вот:
01-29 01:29:44.749 1818 1818 E
AndroidRuntime
FATAL EXCEPTION: main 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
Process: by.sviter.allbestlessons, PID: 1818 01-29 01:29:44.749 1818 1818 E AndroidRuntime
android.view.InflateException: Binary XML file line #26: Error inflating class fragment 01-29 01:29:44.749 1818 1818 E AndroidRuntime
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:763) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.view.LayoutInflater.rInflate(LayoutInflater.java:809) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.view.LayoutInflater.inflate(LayoutInflater.java:504) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.view.LayoutInflater.inflate(LayoutInflater.java:414) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at by.sviter.allbestlessons.risunok_item.Risunok_page11.onCreateView(Risunok_page11.java:41) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.os.Handler.handleCallback(Handler.java:739) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.os.Handler.dispatchMessage(Handler.java:95) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.os.Looper.loop(Looper.java:135) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.app.ActivityThread.main(ActivityThread.java:5221) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at java.lang.reflect.Method.invoke(Native Method) 01-29 01:29:44.749 1818 1818 E AndroidRuntime
at java.lang.reflect.Method.invoke(Method.java:372) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
Caused by: java.lang.ClassCastException: com.google.android.youtube.player.YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.Fragment.instantiate(Fragment.java:402) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.Fragment.instantiate(Fragment.java:377) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.support.v4.app.FragmentActivity.onCreateView(FragmentActivity.java:277) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) 01-29 01:29:44.749 1818 1818 E
AndroidRuntime
... 19 more