RecyclerView + JSON Parsing
RecyclerView + JSON Parsing:
RecyclerView + JSON Parsing" in the context of Android development, it usually refers to the process of fetching data in JSON format from an external source (like a web API), parsing that JSON data, and displaying it in a RecyclerView.
Example:
// app/build.gradle
implementation 'com.google.android.material:material:1.3.0'
<!-- activity_main.xml -->
<RelativeLayout 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=".MainActivity">
<Button
android:id="@+id/show_data"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Show Data"
android:textSize="18sp"
android:textColor="@color/colorWhite"
android:background="@color/colorPrimaryDark"
android:layout_margin="6dp"
android:textAllCaps="false"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/show_data"/>
</RelativeLayout>
<!-- custom_recycler_json.xml -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:padding="6dp">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="10dp"
app:contentPadding="6dp"
android:layout_margin="4dp"
android:scrollbars="vertical"
android:focusable="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="8dp"
android:orientation="vertical"
android:gravity="center">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
android:textSize="18sp"
android:textStyle="bold"
android:padding="3dp"
android:textColor="@color/colorPrimaryDark"/>
<TextView
android:id="@+id/age"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Age"
android:textSize="16sp"
android:padding="3dp"
android:textColor="@color/colorBlack"/>
<TextView
android:id="@+id/city"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="City"
android:textSize="18sp"
android:padding="3dp"
android:textColor="@color/colorOrange"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>