Commit 4f6c5a74 authored by Ahmad Abi Mulya's avatar Ahmad Abi Mulya

add recycleview buttons for category

parent 92075dc6
......@@ -5,6 +5,7 @@ import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import android.Manifest;
......@@ -98,6 +99,7 @@ public class MainActivity extends AppCompatActivity {
popupMenu.show();
});
binding.rvCategory.setLayoutManager(new LinearLayoutManager(MainActivity.this, LinearLayoutManager.HORIZONTAL, false));
binding.rvProducts.setAdapter(adapter);
viewModel = new ViewModelProvider(this).get(ProductViewModel.class);
viewModel.getProducts().observe(this, adapter::setProducts);
......
......@@ -24,7 +24,7 @@
<View
android:id="@+id/rectangle_4"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="150dp"
android:background="@drawable/rectangle_4"
app:layout_constraintBottom_toTopOf="@id/rvProducts"
app:layout_constraintEnd_toEndOf="parent"
......@@ -113,13 +113,22 @@
android:imeOptions="actionSearch"
android:inputType="textCapWords"
android:textSize="@dimen/text_default" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvCategory"
android:layout_width="match_parent"
android:layout_height="0dp"
tools:listitem="@layout/category_item"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/rectangle_4"
app:layout_constraintBottom_toTopOf="@id/rvProducts"
/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvProducts"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginVertical="15dp"
app:layout_constraintTop_toBottomOf="@id/rectangle_4"
app:layout_constraintTop_toBottomOf="@id/rvCategory"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
......
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>
<variable
name="category"
type="String" />
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:paddingVertical="10dp"
android:layout_marginHorizontal="3dp">
<com.google.android.material.card.MaterialCardView
android:id="@+id/cvCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="@color/colorPrimaryDark"
android:clickable="true"
android:focusable="true"
android:checkable="true"
app:cardCornerRadius="10dp"
android:clipToPadding="true"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="20dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#fff"
tools:text="elizabeth"
android:layout_centerInParent="true"/>
</RelativeLayout>
</com.google.android.material.card.MaterialCardView>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment