私は Fragment を見ようとしているだけで、ばかげたものでいくつかの問題を抱えています... 私の SkippersActivity.java があります:
public class SkippersActivity extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.skippers_fragment);
}
}
そして私のskipers_fragment.xml:
<?xml version="1.0" encoding="utf-8"?>
<fragment
xmlns:android="http://schemas.android.com/apk/res/android"
android:name="com.arkezis.globedroid.SkippersFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/skippers_fragment">
</fragment>
そして私の SkippersFragment.xml があります:
public class SkippersFragment extends Fragment{
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
View mainView = inflater.inflate(R.layout.skippers, container, false);
return mainView;
}
}
私のskipers.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView android:id="@+id/list_skippers_all"
android:layout_width="match_parent"
android:layout_height="match_parent">
</ListView>
</LinearLayout>
なぜ私は得たのですか:
04-30 13:45:16.355: E/AndroidRuntime(30077): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.arkezis.globedroid/com.arkezis.globedroid.SkippersActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread.access$600(ActivityThread.java:123)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.os.Handler.dispatchMessage(Handler.java:99)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.os.Looper.loop(Looper.java:137)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread.main(ActivityThread.java:4424)
04-30 13:45:16.355: E/AndroidRuntime(30077): at java.lang.reflect.Method.invokeNative(Native Method)
04-30 13:45:16.355: E/AndroidRuntime(30077): at java.lang.reflect.Method.invoke(Method.java:511)
04-30 13:45:16.355: E/AndroidRuntime(30077): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
04-30 13:45:16.355: E/AndroidRuntime(30077): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
04-30 13:45:16.355: E/AndroidRuntime(30077): at dalvik.system.NativeStart.main(Native Method)
04-30 13:45:16.355: E/AndroidRuntime(30077): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class fragment
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:697)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-30 13:45:16.355: E/AndroidRuntime(30077): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Activity.setContentView(Activity.java:1835)
04-30 13:45:16.355: E/AndroidRuntime(30077): at com.arkezis.globedroid.SkippersActivity.onCreate(SkippersActivity.java:19)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Activity.performCreate(Activity.java:4465)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
04-30 13:45:16.355: E/AndroidRuntime(30077): ... 11 more
04-30 13:45:16.355: E/AndroidRuntime(30077): Caused by: java.lang.ClassCastException: com.arkezis.globedroid.SkippersFragment cannot be cast to android.app.Fragment
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Fragment.instantiate(Fragment.java:574)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Fragment.instantiate(Fragment.java:549)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.app.Activity.onCreateView(Activity.java:4235)
04-30 13:45:16.355: E/AndroidRuntime(30077): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:673)