我为包含cardview和recycler视图的布局创建了一个xml。在我将视图扩展为片段后,一切正常工作。场景是当我点击按钮时,适配器将新数据推送到回收器视图。数据被正常推动但是recyclerview没有显示布局导致layout_width和height。 我的问题是如何正确显示回收者视图
我认为错误在于我的id = recycler_view_daftar_barang 对不起,我的英语不好 这是我的XML代码
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/grey"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardCornerRadius="2dp"
app:cardElevation="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="8dp">
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_tanggal_so"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_tanggal_so"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/tanggal_so" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_pelanggan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<AutoCompleteTextView
android:id="@+id/auto_complete_pelanggan"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/pelanggan_nama" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_keterangan"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="@+id/edit_text_keterangan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/keterangan" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardCornerRadius="2dp"
app:cardElevation="3dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_daftar_barang"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardCornerRadius="2dp"
app:cardElevation="3dp">
<android.support.v7.widget.AppCompatButton
android:id="@+id/so_tambah_barang"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/barang_tambah" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
app:cardCornerRadius="2dp"
app:cardElevation="3dp">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_subtotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/edit_text_subtotal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:editable="false"
android:hint="@string/subtotal" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_pajak"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/edit_text_pajak"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/pajak"
android:inputType="numberDecimal" />
</android.support.design.widget.TextInputLayout>
</TableRow>
<TableRow>
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_potongan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<EditText
android:id="@+id/edit_text_potongan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/potongan" />
</android.support.design.widget.TextInputLayout>
</TableRow>
</TableLayout>
</android.support.v7.widget.CardView>
</LinearLayout>