仅在将兼容性库用于 3.0 之前的设备时才会发生这种情况
我收到一个我无法确定的错误。我有一个带有 ListFragment 和标准 Fragment 的 Activity。它就像 Android 开发指南的开发者部分中提供的示例一样。
ListFragment 子类(没有重写函数)
public class ItemListFragment extends ListFragment
主要活动
public class ItemViewerActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.item_viewer);
    }
}
MainActivity 的 XML 布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="horizontal">
  <fragment class="org.example.ItemListFragment"
    android:id="@+id/item_list_fragment"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1" />
  <FrameLayout
    android:id="@+id/item_info_frame"
    android:layout_width="0dp"
    android:layout_height="fill_parent"
    android:layout_weight="1" />
</LinearLayout>
来自 LogCat 的错误消息
错误/AndroidRuntime:原因:java.lang.ClassCastException:org.example.ItemListFragment 无法转换为 android.app.Fragment