0

Loading a list from Json the model is :

message: success
ResponseData": [
    {
        "RecordEntryOn": "2022-01-25T00:00:00",
        "PatientID": 4934,
        "DiscountedAmount": 1380248.0,
        "ClientID": 0,
        "TestType": "Test",
        "TestName": null,
        "fetchingTime": "0001-01-01T00:00:00",
        
    },
{
        "RecordEntryOn": "2022-01-25T00:00:00",
        "PatientID": 1605,
        "DiscountedAmount": 446590.0,
        "ClientID": 0,
        "TestType": "Test",
        "TestName": "Custom package",
        "fetchingTime": "0001-01-01T00:00:00",
        
    },
.....//more entries////

Kindly look carefully the first record represents total revenue for the date and than the normal list by test name in first record TestName is null and than all entires have a test name. The first record of list is total revenue for the selected date (selected from calendar)

I have to display the first entry as

**Date : Revenue :**

and than the normal list as

**Test Name:  Revenue: Patient Count:**

I used multiple view to achieve the same everything is working fine but the Date in first entry is not showing, Revenue is showing correctly I tried :

textview1.setText(String.valueof(response.getRecordyEntryOn());
Result of above is Date : null

If I am formatting it as simple date format than it is showing nothing

Date :

like above

This is how i am defining RecordyEntry in model:

@SerializedName("RecordEntryON")
@Expose
private Date record_EntryOn;

public Date getRecord_EntryOn() {
    return record_EntryOn;
}

My getItemView in adapter :

public int getItemViewType(int position) {


    if ((testResponseList.get(position).getTest_Name()) == null) {
        return revenue_list;
    } else
        return main_list;
}

revenue_list is for Total revenue part where I want to show Revenue and date only

main_list is the layout where i am showing all other fields

whats the issue here I am not figuring it out kindly help

tintin
  • 335
  • 2
  • 8

1 Answers1

0

In your model class, you've used @SerializedName("RecordEntryON"). Note the ON in caps, but in the response, the key is "RecordEntryOn", (Small case n).

Try this:

@SerializedName("RecordEntryOn")
@Expose
private Date record_EntryOn;

public Date getRecord_EntryOn() {
    return record_EntryOn;
}

Edit: Take a look at this link for formatting your date.

rdias002
  • 214
  • 2
  • 9
  • yes i figured it out it was a typo.....i changed it to RecordEntryOn and getter also and than no data blank screen whats the issue here i am not getting it – tintin Feb 02 '22 at 07:48
  • Your response is a string but you've defined the field as a Date. Have you written a json converter for converting string to date? – rdias002 Feb 02 '22 at 08:36
  • Ralph thanks a lot ...resolved both of your points worked...date was the issue as I have to show date in UI so I am converting it after getting as String – tintin Feb 02 '22 at 17:59