How to Parsing JsonArray using with RecyclerView Android using Volley

Hi Everyone in this tutorial, I am Sharing how to Parsing a  JsonArry List data in android. I am Parsing array list data to used recycler list to show data.

I have explained how to Parse JSON in Android using Json Volley. In this tutorial, we will see how we can easily do the same using Volley library.

What is Volley?

Volley is a Json Parsing library that makes networking for Android apps easier, and faster. You need not create an AsyncTask for running network operation in the background. Volley does this by itself by creating an asynchronous task.

Volley offers the following benefits:

  • Automatic scheduling of network requests.
  • Multiple concurrent network connections.
  • Support for request prioritization.
  • Cancellation request API. You can cancel a single request, or you can set blocks or scopes of requests to cancel.
  • Ease of customization.
  • Strong ordering that makes it easy to correctly populate your UI with data fetched asynchronously from the network.
  • Debugging and tracing tools.

Step 1: Firstly Create a Project in your Android Studio.

open your Gradle Scripts App-Based build. Gradle.

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:28.+'
    compile 'com.android.support:design:28.+'
    compile 'com.android.support:support-v4:28.+'
    compile 'de.hdodenhof:circleimageview:2.1.0'
    compile 'com.android.support:cardview-v7:28.+'
    compile 'com.android.support:recyclerview-v7:28.+'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.volley:volley:1.0.0'
    testCompile 'junit:junit:4.12'
}

Step 2:  Add Internet permission to AndroidManifest.xml

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

Step 3: Open Your activity_main.XML  and add this code.

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.codeplayon.Main_Activity">

    <android.support.v4.widget.SwipeRefreshLayout
        android:id="@+id/Refres_List"
        android:layout_height="match_parent"
        android:layout_width="match_parent">

        <android.support.v7.widget.RecyclerView
            android:id="@+id/Recycler_List"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scrollbars="vertical" />
    </android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout

Step 4: Open Your Main.JAVA file and add this code.

public class Main extends AppCompatActivity implements SwipeRefreshLayout.OnRefreshListener{
    public static final String KEY_Email = "userId";
    private RecyclerView recyclerView;
    private SwipeRefreshLayout swipeRefreshLayout;
    private Visiter_Adupter rAdapter;
    public static String EMAIL="";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        SessionManagement sessionManagement = new SessionManagement();
        EMAIL = sessionManagement.getSavedEmail(this);

        if (AppStatus.getInstance(this).isOnline()) {
            Complete_Visit();

        } else {
            ContextThemeWrapper ctw = new ContextThemeWrapper(Main.this, R.style.Theme_AlertDialog);
            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
            alertDialogBuilder.setTitle("No internet connection");
            alertDialogBuilder.setMessage("Check your  internet connection or try again");
            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {

                }
            });
            alertDialogBuilder.show();
        }

        swipeRefreshLayout = (SwipeRefreshLayout)findViewById(R.id.Refres_List);
        swipeRefreshLayout.setOnRefreshListener(this);
        this.setTitle("List data");
    }

    private void Complete_Visit() {
        final ProgressDialog loading = new ProgressDialog(Complete_Visit.this);
        loading.setMessage("Please Wait...");
        loading.setCancelable(false);
        loading.show();
// json response code
        StringRequest stringRequest = new StringRequest(Request.Method.POST, ConfiURL.Complete_Visit_URL,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            Log.d("JSON", response);
                            loading.dismiss();
                            swipeRefreshLayout.setRefreshing(false);
                            JSONObject jsonObject = new JSONObject(response);
                            String error_status = jsonObject.getString("status");
                            if (error_status.equals("0")) {
                                String error_msg = jsonObject.getString("message");
//                                Toast.makeText(LogIn.this, error_msg, Toast.LENGTH_SHORT).show();
                                ContextThemeWrapper ctw = new ContextThemeWrapper( Main.this, R.style.Theme_AlertDialog);
                                final android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(ctw);
                                alertDialogBuilder.setTitle("Message");
                                alertDialogBuilder.setMessage(error_msg);
                                alertDialogBuilder.setCancelable(false);
                                alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int id) {

                                    }
                                });
                                alertDialogBuilder.show();
                            } else {
                                JSONArray jArray = jsonObject.getJSONArray("allData");
                                if (jArray.length() == 0) {
 /*of array length is 0 then show alert dialog if
 * array is not 0 then go else*/
                                    ContextThemeWrapper ctw = new ContextThemeWrapper( Main.this, R.style.Theme_AlertDialog);
                                    final android.app.AlertDialog.Builder alertDialogBuilder = new android.app.AlertDialog.Builder(ctw);
                                    alertDialogBuilder.setTitle("Message");
                                    alertDialogBuilder.setMessage(" No data found please try after sometime ");
                                    alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                        public void onClick(DialogInterface dialog, int id) {

                                        }
                                    });
                                    alertDialogBuilder.show();
                                } else {
                                    onPostExecute(jArray);

                                }

                            }

                        } catch (Exception e) {
                            loading.dismiss();
                            swipeRefreshLayout.setRefreshing(false);
                            Log.d("Tag", e.getMessage());

                        }
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        loading.dismiss();
                        swipeRefreshLayout.setRefreshing(false);
                        if (error instanceof TimeoutError || error instanceof NoConnectionError) {
                            ContextThemeWrapper ctw = new ContextThemeWrapper( Complete_Visit.this, R.style.Theme_AlertDialog);
                            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
                            alertDialogBuilder.setTitle("No connection");
                            alertDialogBuilder.setMessage(" Network Timeout  error please try again ");
                            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                            alertDialogBuilder.show();
                        } else if (error instanceof AuthFailureError) {
                            ContextThemeWrapper ctw = new ContextThemeWrapper( Main.this, R.style.Theme_AlertDialog);
                            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
                            alertDialogBuilder.setTitle("Connection Error");
                            alertDialogBuilder.setMessage(" Connection authentication failure  error please try again");
                            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                            alertDialogBuilder.show();
                            //TODO
                        } else if (error instanceof ServerError) {
                            ContextThemeWrapper ctw = new ContextThemeWrapper( Main.this, R.style.Theme_AlertDialog);
                            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
                            alertDialogBuilder.setTitle("Connection Error");
                            alertDialogBuilder.setMessage("Connection error please try again");
                            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                            alertDialogBuilder.show();
                            //TODO
                        } else if (error instanceof NetworkError) {
                            ContextThemeWrapper ctw = new ContextThemeWrapper( Main.this, R.style.Theme_AlertDialog);
                            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
                            alertDialogBuilder.setTitle("Connection Error");
                            alertDialogBuilder.setMessage("Network connection error please try again");
                            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                            alertDialogBuilder.show();
                            //TODO
                        } else if (error instanceof ParseError) {
                            ContextThemeWrapper ctw = new ContextThemeWrapper( Maim.this, R.style.Theme_AlertDialog);
                            final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(ctw);
                            alertDialogBuilder.setTitle("Error");
                            alertDialogBuilder.setMessage("Parse error");
                            alertDialogBuilder.setPositiveButton("ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int id) {

                                }
                            });
                            alertDialogBuilder.show();
                        }
                    }
                }) {
            @Override
            protected Map<String, String> getParams() throws AuthFailureError {
                Map<String, String> map = new HashMap<String, String>();
                map.put(KEY_Email,EMAIL);
                return map;
            }
        };

        RequestQueue requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(stringRequest);
    }
    protected void onPostExecute(JSONArray result) {

        //this method will be running on UI thread
        List<DataObject> data = new ArrayList<>();
        data.equals(null);
        try {
            // Extract data from json and store into ArrayList as class objects
            for (int i = 0; i < result.length(); i++) {
                JSONObject json_data = result.getJSONObject(i);
                DataObject report = new DataObject();
                report.mText1 = json_data.getString("id");
                report.mText2 = json_data.getString("patientName");
                report.mText3 = json_data.getString("package_id");
                report.mText4 = json_data.getString("visit_type");
                report.mText5 = json_data.getString("app_booked_date");
                report.mText6=json_data.getString("app_booked_time");
                report.mText7 = json_data.getString("total_seats");
                report.mText8 = json_data.getString("no_of_seats");
                report.mText9=json_data.getString("due_days");
                report.mText10=json_data.getString("appointmentType");
                report.mText11=json_data.getString("packageName");
                report.mText12=json_data.getString("packageAmount");
                report.mText13=json_data.getString("packageDays");
                report.mText14=json_data.getString("in_time");
                report.mText15=json_data.getString("out_time");
                report.mText16=json_data.getString("rating");
                report.mText17=json_data.getString("patientService");
                report.mText19=json_data.getString("patient_id");
                report.mText20 = json_data.getString("appointment_id");
                report.Image=json_data.getString("patientProfilePicture");
                data.add(report);
            }
            // Setup and Handover data to recyclerview
            recyclerView = (RecyclerView) findViewById(R.id.Recycler_List);
            rAdapter = new Visiter_Adupter(Complete_Visit.this, data);
            recyclerView.setAdapter(rAdapter);
            recyclerView.setLayoutManager(new LinearLayoutManager(main.this));

        } catch (JSONException e) {
            Toast.makeText(Complete_Visit.this, e.toString(), Toast.LENGTH_LONG).show();
        }
    }


    @Override
    public void onRefresh() {
        Complete_Visit();

    }

}

Step 5: Create a Java Class recycler list Adapter Class.

public class Visiter_Adupter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    public static final String KEY_userId = "userId";//database key
    public static final String KEY_visitId = "visitId";

    private Context context;
    private LayoutInflater inflater;
    List<DataObject> data = Collections.emptyList();
    private ArrayList<DataObject> arraylist;
    private int lastPosition = -1;
    String User_id,Visit_Id;

    public Visiter_Adupter(Context context, List<DataObject> data) {
        this.context = context;
        // inflater = LayoutInflater.from(context);
        this.data = data;
        this.arraylist = new ArrayList<DataObject>();
        this.arraylist.addAll(data);
    }

    // Inflate the layout when viewholder created
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.from(parent.getContext()).
                inflate(R.layout.visitor_view, parent, false);
        Visiter_Adupter.MyHolder holder = new Visiter_Adupter.MyHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

        // Get current position of item in recyclerview to bind data and assign values from list
        Visiter_Adupter.MyHolder myHolder = (Visiter_Adupter.MyHolder) holder;
        DataObject current = data.get(position);
        myHolder.visit_id.setText(current.getmText1());
        myHolder.visit_Name.setText(current.getmText2());
        myHolder.visit_Pack_id.setText(current.getmText3());
        myHolder.visit_Type.setText(current.getmText4());
        myHolder.visit_Date.setText("Date:  "+current.getmText5());
        myHolder.visit_Time.setText("Time:  "+current.getmText6());
        myHolder.visit_total_seats.setText("Total Visits:  "+current.getmText7());
        myHolder.visit_no_of_seats.setText("Seats:  "+current.getmText8());
        myHolder.visit_due_days.setText("Due:  "+current.getmText9());
        myHolder.visit_Appment_type.setText(current.getmText10());
        myHolder.packageName.setText(current.getmText11());
        myHolder.packageAmount.setText("INR  "+current.getmText12());
        myHolder.packageDays.setText("Days:  "+current.getmText13());
        myHolder.InTime.setText(current.getmText14());
        myHolder.OutTime.setText(current.getmText15());
        String rating=current.getmText16();
        myHolder.patientService.setText(current.getmText17());
        myHolder.Patient_Id.setText(current.getmText19());
        if(rating.equals("")){

        }else {
            myHolder.ratingBar.setRating(Float.parseFloat(rating));

        }
        


        String userImage=current.getImage();
        if (userImage.isEmpty()) {
            Toast.makeText(context,"no image for user",Toast.LENGTH_LONG).show();
        } else {
            Picasso.with(context)
                    .load(userImage)
                    .placeholder(R.drawable.icon_user)
                    .into(myHolder.Visit_Image);
        }
    }

    @Override
    public int getItemCount() {
        return data.size();
    }


    class MyHolder extends RecyclerView.ViewHolder {

        TextView visit_id;
        TextView visit_Name;
        TextView visit_Type;
        TextView packageName;
        TextView packageAmount;
        TextView packageDays;
        TextView visit_Appment_type;
        TextView visit_total_seats;
        TextView visit_no_of_seats;
        TextView visit_due_days;
        TextView visit_Date;
        TextView visit_Time;
        TextView visit_Pack_id;
        ImageView Visit_Image;
        RatingBar ratingBar;
        TextView InTime;
        TextView OutTime;
        TextView patientService;
        TextView SeeMore;
        TextView Attend;
        TextView HiddenBtn;
        TextView Add_Visit_Btn;
        TextView ReportBtn;
        TextView Patient_Id;
        TextView appointment_id;
        LinearLayout linearLayout;
        // create constructor to get widget reference
        public MyHolder(View itemView) {
            super(itemView);
            appointment_id= (TextView) itemView.findViewById(R.id.appointment_id);
            visit_id = (TextView) itemView.findViewById(R.id.visit_id);
            Patient_Id=(TextView) itemView.findViewById(R.id.Visit_Patient_Id);
            visit_Pack_id = (TextView) itemView.findViewById(R.id.visit_Pack_id);
            visit_Name = (TextView) itemView.findViewById(R.id.visit_Name);
            visit_Type = (TextView) itemView.findViewById(R.id.visit_Type);
            packageName = (TextView) itemView.findViewById(R.id.packageName);
            packageAmount = (TextView) itemView.findViewById(R.id.packageAmount);
            packageDays = (TextView) itemView.findViewById(R.id.packageDays);
            visit_Appment_type = (TextView) itemView.findViewById(R.id.visit_Appment_type);
            visit_total_seats = (TextView) itemView.findViewById(R.id.visit_total_seats);
            visit_no_of_seats = (TextView) itemView.findViewById(R.id.visit_no_of_seats);
            visit_due_days = (TextView) itemView.findViewById(R.id.visit_due_days);
            visit_Date = (TextView) itemView.findViewById(R.id.visit_Date);
            visit_Time = (TextView) itemView.findViewById(R.id.visit_Time);
            Visit_Image=(ImageView)itemView.findViewById(R.id.Visit_Image);
            ratingBar=(RatingBar)itemView.findViewById(R.id.ratingBar1);
            InTime=(TextView)itemView.findViewById(R.id.visit_InTime);
            OutTime=(TextView)itemView.findViewById(R.id.visit_OutTime);
            linearLayout=(LinearLayout)itemView.findViewById(R.id.Hidden_Layout);
            patientService=(TextView)itemView.findViewById(R.id.patientService);
            ReportBtn=(TextView)itemView.findViewById(R.id.ReportBtn);
            Add_Visit_Btn=(TextView)itemView.findViewById(R.id.Add_Visit_Btn);

           
        }
    }

Step 6:  CardView layout in XML.

create an XML file and manage a UI for show data in card view. hare I am using a card view to create a good UI for show data in card.

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/tools"
    android:id="@+id/card_view"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="5dp"
    android:layout_marginBottom="3dp"
    card_view:cardBackgroundColor="@color/white"
    android:layout_marginRight="5dp"
    android:layout_marginLeft="5dp"
    card_view:cardCornerRadius="8dp">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:padding="5dp"
        android:orientation="vertical">
       <LinearLayout
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:orientation="horizontal">

           <de.hdodenhof.circleimageview.CircleImageView
               android:id="@+id/Visit_Image"
               android:layout_width="70dp"
               android:layout_height="70dp"
               android:layout_gravity="center"
               android:src="@drawable/icon_user"
               app:civ_border_color="@color/colorAccent"
               app:civ_border_width="2dp" />

           <LinearLayout
               android:layout_width="match_parent"
               android:layout_height="wrap_content"
               android:orientation="vertical">
               <TextView
                   android:id="@+id/visit_id"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:visibility="gone"
                   android:textAppearance="?android:textAppearanceMedium"
                   android:text=""/>

               <TextView
                   android:id="@+id/appointment_id"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:visibility="gone"
                   android:textAppearance="?android:textAppearanceMedium"
                   android:text=""/>
               <TextView
                   android:id="@+id/visit_Pack_id"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:visibility="gone"
                   android:textAppearance="?android:textAppearanceMedium"
                   android:text=""/>

               <TextView
                   android:id="@+id/Visit_Patient_Id"
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:visibility="gone"
                   android:textAppearance="?android:textAppearanceMedium"
                   android:text=""/>
               <View
                   android:layout_width="match_parent"
                   android:layout_height="1dp"
                   android:background="@color/gree"/>
               <LinearLayout
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal">
                   <TextView
                       android:id="@+id/visit_Name"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:layout_weight="1"
                       android:padding="3dp"
                       android:textStyle="bold"
                       android:textAppearance="?android:textAppearanceSmall"
                       android:text=""/>
                   <View
                       android:layout_width="1dp"
                       android:layout_height="match_parent"
                       android:background="@color/gree"/>
                   <TextView
                       android:id="@+id/visit_Appment_type"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:layout_weight="1"
                       android:textStyle="bold"
                       android:padding="3dp"
                       android:textAppearance="?android:textAppearanceSmall"
                       android:text=""/>

               </LinearLayout>

               <View
                   android:layout_width="match_parent"
                   android:layout_height="1dp"
                   android:background="@color/gree"/>
               <LinearLayout
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal">
                   <TextView
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text="Patient Service "
                       android:textStyle="bold"/>
                   <View
                       android:layout_width="1dp"
                       android:layout_height="match_parent"
                       android:background="@color/gree"/>
                   <TextView
                       android:id="@+id/patientService"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text=" " />
               </LinearLayout>
               <View
                   android:layout_width="match_parent"
                   android:layout_height="1dp"
                   android:background="@color/gree"/>
               <LinearLayout
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal">
                   <TextView
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text=" Package Name"
                       android:textStyle="bold"/>
                   <View
                       android:layout_width="1dp"
                       android:layout_height="match_parent"
                       android:background="@color/gree"/>
                   <TextView
                       android:id="@+id/packageName"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text=" ----- " />
               </LinearLayout>
               <View
                   android:layout_width="match_parent"
                   android:layout_height="1dp"
                   android:background="@color/gree"/>
               <LinearLayout
                   android:layout_width="match_parent"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal">
                   <TextView
                       android:id="@+id/packageAmount"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text="------- " />
                   <View
                       android:layout_width="1dp"
                       android:layout_height="match_parent"
                       android:background="@color/gree"/>
                   <TextView
                       android:id="@+id/packageDays"
                       android:layout_width="match_parent"
                       android:layout_height="wrap_content"
                       android:padding="3dp"
                       android:layout_weight="1"
                       android:text=" ------ " />
               </LinearLayout>

           </LinearLayout>
       </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/gree"/>
        <LinearLayout
            android:id="@+id/Hidden_Layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="horizontal">
            <TextView
                android:id="@+id/visit_total_seats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="3dp"
                android:textAppearance="?android:textAppearanceSmall"
                android:text="-------"/>
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@color/gree"/>
            <TextView
                android:id="@+id/visit_no_of_seats"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1.5"
                android:padding="3dp"
                android:textAppearance="?android:textAppearanceSmall"
                android:text="--------"/>
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@color/gree"/>
            <TextView
                android:id="@+id/visit_due_days"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1.5"
                android:padding="3dp"
                android:textAppearance="?android:textAppearanceSmall"
                android:text="---------"/>
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/gree"/>
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
            <TextView
                android:id="@+id/visit_Date"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="3dp"
                android:textAppearance="?android:textAppearanceSmall"
                android:text=""/>
            <View
                android:layout_width="1dp"
                android:layout_height="match_parent"
                android:background="@color/gree"/>
            <TextView
                android:id="@+id/visit_Time"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_weight="1"
                android:padding="3dp"
                android:textAppearance="?android:textAppearanceSmall"
                android:text=""/>
        </LinearLayout>
        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/gree"/>


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textStyle="bold"
                    android:padding="3dp"
                    android:textAppearance="?android:textAppearanceSmall"
                    android:text="Visit Type"/>
                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="@color/gree"/>
                <TextView
                    android:id="@+id/visit_Type"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:textStyle="bold"
                    android:padding="3dp"
                    android:textAppearance="?android:textAppearanceSmall"
                    android:text=" ----- "/>

            </LinearLayout>
            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/gree"/>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/gree"/>
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="3dp"
                    android:textStyle="bold"
                    android:text="In Time"/>
                <TextView
                    android:id="@+id/visit_InTime"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="3dp"
                    android:textAppearance="?android:textAppearanceSmall"
                    android:text=""/>
                <View
                    android:layout_width="1dp"
                    android:layout_height="match_parent"
                    android:background="@color/gree"/>
                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="3dp"
                    android:textStyle="bold"
                    android:text="Out Time"/>
                <TextView
                    android:id="@+id/visit_OutTime"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:padding="3dp"
                    android:textAppearance="?android:textAppearanceSmall"
                    android:text=""/>
            </LinearLayout>

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/gree"/>
            <RatingBar
                android:id="@+id/ratingBar1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:progressTint="@color/colorPrimary"
                android:backgroundTint="@color/colorAccent"
                android:secondaryProgressTint="@color/colorPrimaryDark" />

            <View
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:background="@color/gree"/>
        </LinearLayout>
    </LinearLayout>
</android.support.v7.widget.CardView>

Step 7: Java DateObject class Get And Set Value.

here you can create a java class for getter and setter value

public class DataObject {
    public String mText1;
    public String mText2;
    public String mText3;
    public String mText4;
    public String mText5;
    public String mText6;
    public String mText7;
    public String mText8;
    public String mText9;
    public String mText10;
    public String mText11;
    public String mText12;
    public String mText13;
    public String mText14;
    public String mText15;
    public String mText16;
    public String mText17;
    public String mText18;
    public String mText19;
    public String mText20;
    public String Image;
    

    public String getImage() {
        return Image;
    }

    public void setImage(String image) {
        Image = image;
    }
    public String getmText1() {
        return mText1;
    }

    public void setmText1(String mText1) {
        this.mText1 = mText1;
    }

    public String getmText2() {
        return mText2;
    }

    public void setmText2(String mText2) {
        this.mText2 = mText2;
    }

    public String getmText3() {
        return mText3;
    }

    public void setmText3(String mText3) {
        this.mText3 = mText3;
    }

    public String getmText4() {
        return mText4;
    }

    public void setmText4(String mText4) {
        this.mText4 = mText4;
    }

    public String getmText5() {
        return mText5;
    }

    public void setmText5(String mText5) {
        this.mText5 = mText5;
    }
    public String getmText6() {
        return mText6;
    }

    public void setmText6(String mText6) {
        this.mText6 = mText6;
    }

    public String getmText7() {
        return mText7;
    }

    public void setmText7(String mText7) {
        this.mText7 = mText7;
    }
    public String getmText8() {
        return mText8;
    }

    public void setmText8(String mText8) {
        this.mText8 = mText8;
    }
    public String getmText9() {
        return mText9;
    }

    public void setmText9(String mText9) {
        this.mText9 = mText9;
    }

    public String getmText10() {
        return mText10;
    }

    public void setmText10(String mText10) {
        this.mText10 = mText10;
    }

    public String getmText11() {
        return mText11;
    }

    public void setmText11(String mText11) {
        this.mText11 = mText11;
    }

    public String getmText12() {
        return mText12;
    }

    public void setmText12(String mText12) {
        this.mText12 = mText12;
    }


    public String getmText13() {
        return mText13;
    }

    public void setmText13(String mText13) {
        this.mText13 = mText13;
    }

    public String getmText14() {
        return mText14;
    }

    public void setmText14(String mText14) {
        this.mText14 = mText14;
    }

    public String getmText15() {
        return mText15;
    }

    public void setmText15(String mText15) {
        this.mText15 = mText15;
    }

    public String getmText16() {
        return mText16;
    }

    public void setmText16(String mText16) {
        this.mText16 = mText16;
    }

    public String getmText17() {
        return mText17;
    }

    public void setmText17(String mText17) {
        this.mText17 = mText17;
    }

    public String getmText18() {
        return mText18;
    }

    public void setmText18(String mText18) {
        this.mText18 = mText18;
    }

    public String getmText19() {
        return mText19;
    }

    public void setmText19(String mText19) {
        this.mText19 = mText19;
    }

    public String getmText20() {
        return mText20;
    }

    public void setmText20(String mText20) {
        this.mText20 = mText20;
    }
}
}
Facebooktwitterredditpinterestlinkedinmail
Recommended
Hi  Everyone in this article I am sharing How To…