Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在一个cardview中填充所有行_Java_Android_Xamarin - Fatal编程技术网

Java 在一个cardview中填充所有行

Java 在一个cardview中填充所有行,java,android,xamarin,Java,Android,Xamarin,有没有办法将所有行填充(包装)成一个cardwiew。不要为每行创建CardView 这是我的xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="match_pare

有没有办法将所有行填充(包装)成一个
cardwiew
。不要为每行创建
CardView

这是我的xml

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
                android:weightSum="98"
   >
  <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        xmlns:card_view="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        card_view:cardCornerRadius="10dp"
        card_view:cardElevation="5dp"
        card_view:cardUseCompatPadding="true">

    <TextView
        android:text="Description"
        android:textSize="20sp"
        android:id="@+id/Name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="18" />
    <TextView
        android:text="Quantity"
        android:textSize="20sp"
        android:id="@+id/Quantity"
        android:gravity="right"
        android:textAlignment="gravity"
        android:layout_width="match_parent"

        android:layout_height="wrap_content"
        android:layout_weight="20" />
    <TextView
        android:text="Price"
        android:id="@+id/Price"
        android:textSize="20sp"
         android:gravity="right"
        android:textAlignment="gravity"

        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_weight="20" />
    <TextView
        android:text="Sum"
        android:id="@+id/SumPrice"
        android:textSize="20sp"
       android:gravity="right"
        android:textAlignment="gravity"

        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        android:layout_weight="20" />
    <TextView
        android:text="Dis.Price"
        android:gravity="right"
        android:textSize="20sp"
        android:textAlignment="gravity"
        android:id="@+id/SumDiscountPrice"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="20" />

  </android.support.v7.widget.CardView>
</LinearLayout>

我需要为所有项目创建一个cardview。或者,如果还有管理的方法,cardview将在哪一行开始或结束。
如果您需要有关我的活动的更多详细信息,请让我知道

将您的RecyclerView包装在您的卡片中查看,而不是项目,这将是您的片段/活动的布局

<android.support.v7.widget.CardView
    android:id="@+id/card_view"
    xmlns:card_view="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    card_view:cardCornerRadius="10dp"
    card_view:cardElevation="5dp"
    android:margin="8dp"
    card_view:cardUseCompatPadding="true">

    <RecyclerView 
     android:layout_width="match_parent"
     android:layout_height="match_parent"/>

</android.support.v7.widget.CardView>

您需要对这两个文件都做一些工作,这意味着您的
主\u文件
,而您的特定项目文件意味着
子\u文件

查找您的
main_文件.xml

<android.support.v7.widget.CardView
android:id="@+id/card_view"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
card_view:cardCornerRadius="10dp"
card_view:cardElevation="5dp"
android:margin="8dp">

<RecyclerView 
 android:layout_width="match_parent"
 android:layout_height="match_parent"/>
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
            android:weightSum="98">
<TextView
    android:text="Description"
    android:textSize="20sp"
    android:id="@+id/Name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="18" />
<TextView
    android:text="Quantity"
    android:textSize="20sp"
    android:id="@+id/Quantity"
    android:gravity="right"
    android:textAlignment="gravity"
    android:layout_width="match_parent"

    android:layout_height="wrap_content"
    android:layout_weight="20" />
<TextView
    android:text="Price"
    android:id="@+id/Price"
    android:textSize="20sp"
     android:gravity="right"
    android:textAlignment="gravity"

    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:layout_weight="20" />
<TextView
    android:text="Sum"
    android:id="@+id/SumPrice"
    android:textSize="20sp"
   android:gravity="right"
    android:textAlignment="gravity"

    android:layout_height="wrap_content"
    android:layout_width="match_parent"
    android:layout_weight="20" />
<TextView
    android:text="Dis.Price"
    android:gravity="right"
    android:textSize="20sp"
    android:textAlignment="gravity"
    android:id="@+id/SumDiscountPrice"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="20" />
</LinearLayout>