Android 工具:listheader不';尽管工具不起作用:listitem不起作用
我有一个片段布局,其中包含以下代码:Android 工具:listheader不';尽管工具不起作用:listitem不起作用,android,android-listview,Android,Android Listview,我有一个片段布局,其中包含以下代码: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_h
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BlankFragment">
<ListView
android:id="@+id/blankList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listheader="@layout/menu_header"
tools:listitem="@layout/fragment_item" />
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:background="#f0f0f0">
<ImageView
android:id="@+id/image_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:paddingBottom="3dp"/>
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/menu_article_text_size"
android:layout_marginStart="16dp"
android:textAppearance="?attr/textAppearanceListItem" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="12dp"
android:id="@+id/view2"
app:cardCornerRadius="40dp"
android:layout_centerHorizontal="true">
<ImageView
android:layout_height="80dp"
android:layout_width="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ic_launcher_background"
android:scaleType="centerCrop"/>
</android.support.v7.widget.CardView>
</LinearLayout>
My fragment_项包含以下代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BlankFragment">
<ListView
android:id="@+id/blankList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listheader="@layout/menu_header"
tools:listitem="@layout/fragment_item" />
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:background="#f0f0f0">
<ImageView
android:id="@+id/image_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:paddingBottom="3dp"/>
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/menu_article_text_size"
android:layout_marginStart="16dp"
android:textAppearance="?attr/textAppearanceListItem" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="12dp"
android:id="@+id/view2"
app:cardCornerRadius="40dp"
android:layout_centerHorizontal="true">
<ImageView
android:layout_height="80dp"
android:layout_width="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ic_launcher_background"
android:scaleType="centerCrop"/>
</android.support.v7.widget.CardView>
</LinearLayout>
“我的菜单”标题包含以下代码:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".BlankFragment">
<ListView
android:id="@+id/blankList"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:listheader="@layout/menu_header"
tools:listitem="@layout/fragment_item" />
</FrameLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="bottom"
android:orientation="horizontal"
android:background="#f0f0f0">
<ImageView
android:id="@+id/image_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:paddingBottom="3dp"/>
<TextView
android:id="@+id/content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/menu_article_text_size"
android:layout_marginStart="16dp"
android:textAppearance="?attr/textAppearanceListItem" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.CardView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="12dp"
android:id="@+id/view2"
app:cardCornerRadius="40dp"
android:layout_centerHorizontal="true">
<ImageView
android:layout_height="80dp"
android:layout_width="match_parent"
android:id="@+id/imageView1"
android:src="@drawable/ic_launcher_background"
android:scaleType="centerCrop"/>
</android.support.v7.widget.CardView>
</LinearLayout>
我的问题是,由于某种原因,当我运行应用程序时,片段工作了,列表出现了,它的项目很好,但是标题根本不存在
有人帮忙吗
*重要事实*
在预览中,它确实可以工作,但当我运行它时就不行了
我的问题是,由于某种原因,当我运行它时,应用程序会出现碎片
工作时,列表会出现,并且列表中的项目很好,但是标题
根本就不存在
- 重要的事实*在预览中,它确实可以工作,但当我运行它时就不行了
android:text=“Hello World
和tools:text=“Hello World“
。您应该使用“工具”属性将演示/测试数据放在布局中,这样用户就不会看到这些数据,但若能看到布局中有可用的视图,这将对开发人员有所帮助。事实上,它们可以调整边距、填充和所有其他布局设计时操作
我的问题是,由于某种原因,当我运行它时,应用程序会出现碎片
工作时,列表会出现,并且列表中的项目很好,但是标题
根本就不存在
- 重要的事实*在预览中,它确实可以工作,但当我运行它时就不行了
通过给你一个例子来说明这一点,
android:text=“Hello World
和tools:text=“Hello World“
。您应该使用“工具”属性将演示/测试数据放在布局中,这样用户就不会看到这些数据,但若能看到布局中有可用的视图,这将对开发人员有所帮助。事实上,它们可以调整边距、填充和所有其他布局设计时操作 首先,非常感谢,但你的回答迫使我问另一个问题,我如何在列表中添加标题@帕雷什Mayani@ItayBraha你是说片头,对吗?如果是,则需要定义两个视图持有者,一个是节标题,另一个是项目视图持有者。更多关于谷歌的信息,很多资源都已经准备好了。首先非常感谢,但是你的回答迫使我问另一个问题,我如何在列表中添加标题@帕雷什Mayani@ItayBraha你是说片头,对吗?如果是,则需要定义两个视图持有者,一个是节标题,另一个是项目视图持有者。更多关于谷歌的信息,很多资源已经可用