简体   繁体   English

在多视图类型回收器视图中显示 null 或没有显示的日期

[英]Date showing null or nothing in multiple view type recycler view

Loading a list from Json the model is:从 Json 加载列表 model 是:

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.请仔细查看第一条记录代表该日期的总收入,并且第一条记录中测试名称的正常列表 TestName 是 null并且所有条目都有一个测试名称。 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:这就是我在 model 中定义 RecordyEntry 的方式:

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

public Date getRecord_EntryOn() {
    return record_EntryOn;
}

My getItemView in adapter:我在适配器中的 getItemView:

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 main_list 是我显示所有其他字段的布局

whats the issue here I am not figuring it out kindly help这里有什么问题我没有弄清楚请帮忙

In your model class, you've used @SerializedName("RecordEntryON") .在您的 model class 中,您使用@SerializedName("RecordEntryON") Note the ON in caps, but in the response, the key is "RecordEntryOn", (Small case n).注意大写的 ON,但在响应中,键是“RecordEntryOn”,(小写 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.编辑:查看此链接以格式化您的日期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM