首页 > 解决方案 > 如何防止在recyclerView中解析相同的日期编号

问题描述

在 json 中有很多相同的日期我想每天只取一个日期,比如 nov-11、nov-12、nov-13,所以我可以每天而不是每小时获取他们的数据并在 recyclerView 中解析它

@Override
public void onBindViewHolder(@NonNull WeatherViewHolder holder, int position) {
    String a = forecasts.get(position).dt_txt;
    String aa= a.substring(5,10);
    String b=  Math.round(forecasts.get(position).getMain().temp) + "°C";

    holder.hourlyTxt.setText(aa);
    holder.hourlyTemp.setText(b);
    Picasso.get().
            load(String.format("http://openweathermap.org/img/w/%s.png", forecasts.get(position).getWeatherList().get(0).icon))
            .into(holder.icon);
}

这是 json https://samples.openweathermap.org/data/2.5/forecast?lat=35&lon=139&appid=b6907d289e10d714a6e88b30761fae22

标签: androidjsonandroid-recyclerview

解决方案


推荐阅读