Android 什么';自定义列表视图有什么问题?

Android 什么';自定义列表视图有什么问题?,android,listview,android-fragments,android-view,Android,Listview,Android Fragments,Android View,启动我的应用程序时,logcat中出现以下错误: 进程:pc.dd.fragment_动画,PID:25093 java.lang.RuntimeException:无法启动活动组件信息{pc.dd.fragment\u animation/pc.dd.fragment\u animation.MainClass}:android.view.InflateException:二进制XML文件行#8:二进制XML文件行#8:膨胀类片段时出错 这在我的xml中的主要活动: <?xml vers

启动我的应用程序时,logcat中出现以下错误:

进程:pc.dd.fragment_动画,PID:25093 java.lang.RuntimeException:无法启动活动组件信息{pc.dd.fragment\u animation/pc.dd.fragment\u animation.MainClass}:android.view.InflateException:二进制XML文件行#8:二进制XML文件行#8:膨胀类片段时出错

这在我的xml中的主要活动:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
    android:id="@+id/listFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:name="pc.dd.fragment_animation.newFragment"
    />
</LinearLayout>
注意:R.id.listFragment位于main_activity.xml中。 下面是代码片段列表视图:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">


    <de.hdodenhof.circleimageview.CircleImageView
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/_fragmentImage"
        android:layout_width="70dp"
        android:layout_height="70dp"
        android:src="@drawable/picture"
        app:civ_border_width="2dp"
        app:civ_border_color="#efefef"
        android:layout_margin="6dp" />

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="@string/nickname"
            android:id="@+id/_fragmentNickanme"
            android:textSize="8pt"
            android:layout_margin="4dp"
            android:layout_gravity="top"
            android:textColor="#282828" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="fill_parent"
            android:textAppearance="?android:attr/textAppearanceMedium"
            android:text="@string/string_small_text"
            android:id="@+id/_fragmentDescription"
            android:textSize="6pt"
            android:gravity="bottom"
            android:layout_margin="4dp" />
    </LinearLayout>

</LinearLayout>


是的,我只是在我的主课上做:

 ListView myListView = (ListView)findViewById(R.id.listMainAct);
    myListAdapter adapter =
            new myListAdapter(this, android.R.layout.simple_list_item_1, items);
    myListView.setAdapter( adapter);

并删除
newFragment
class,thxcricket\u 007以获取提示:)

是的,我只是在我的主课上做:

 ListView myListView = (ListView)findViewById(R.id.listMainAct);
    myListAdapter adapter =
            new myListAdapter(this, android.R.layout.simple_list_item_1, items);
    myListView.setAdapter( adapter);

并删除
newFragment
class,thxcricket\u 007以获取提示:)

您正在尝试将片段加载到列表视图中吗?查看您的片段类<代码>充气器。充气(R.layout.fragment_listview似乎不是您想要的正确布局use@cricket_007,为什么?1)
R.id.listFragment
不是该文件中的id。2)
R.layout.fragment\u listview
也被适配器类用来加载listview的一行。@cricket\u 007,我不知道如何修复它?最好的方法可能是在主类中,只需连接适配器?您是否试图将片段加载到ListView中?查看您的片段类<代码>充气器。充气(R.layout.fragment_listview似乎不是您想要的正确布局use@cricket_007,为什么?1)
R.id.listFragment
不是该文件中的id。2)
R.layout.fragment\u listview
也被适配器类用来加载listview的一行。@cricket\u 007,我不知道如何修复它?最好的方法可能是在主类中,只需连接适配器即可。欢迎使用带有ListView的片段类,您只需要在Java代码中使用正确的XML引用。欢迎使用带有ListView的片段类,您只需要在Java代码中使用正确的XML引用。
 ListView myListView = (ListView)findViewById(R.id.listMainAct);
    myListAdapter adapter =
            new myListAdapter(this, android.R.layout.simple_list_item_1, items);
    myListView.setAdapter( adapter);