- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试解析对象数据列表中的 JSON 数组
payment_details
。
在这里,我已经成功解析了回收站 View 中调用的数据数组,但我无法调用 payment_details
数组。
适配器类
public class InProgress_Adapter extends RecyclerView.Adapter<InProgress_Adapter.InProgressViewHolder> {
private LayoutInflater inflater;
private List<Data_Inprogress> modelRecyclerArrayList;
Context ctx;
public InProgress_Adapter( Context ctx, List<Data_Inprogress> modelRecyclerArrayList) {
this.inflater = inflater.from(ctx);
this.modelRecyclerArrayList = modelRecyclerArrayList;
this.ctx = ctx;
}
@NonNull
@Override
public InProgressViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int viewType) {
View view = inflater.inflate(R.layout.in_progress_adapter, viewGroup, false);
InProgressViewHolder holder = new InProgressViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(@NonNull InProgressViewHolder holder, int i) {
for (i=0;i<modelRecyclerArrayList.size();i++){
holder.location1.setText(modelRecyclerArrayList.get(i).getLocaion());
holder.date1.setText(modelRecyclerArrayList.get(i).getDate());
holder.duration1.setText(modelRecyclerArrayList.get(i).getDuration());
holder.username1.setText(modelRecyclerArrayList.get(i).getUser_name());
holder.workerid1.setText(String.valueOf(modelRecyclerArrayList.get(i).getWork_order_id()));
holder.description1.setText(modelRecyclerArrayList.get(i).getDescription());
holder.useraddress1.setText(modelRecyclerArrayList.get(i).getUser_address());
}
}
@Override
public int getItemCount() {
return modelRecyclerArrayList.size();
}
public class InProgressViewHolder extends RecyclerView.ViewHolder {
TextView location1,date1,username1,duration1,workerid1,description1,useraddress1
,tvorderid,tvdesc,tvusername,tvdate,tvlocation,tvdur,tvaddre,tvpay,tvamt,tvdt,tvcash,tvbal;
public InProgressViewHolder(@NonNull View itemView) {
super(itemView);
Typeface font = Typeface.createFromAsset(ctx.getAssets(),"fonts/Uber Move Text.ttf");
location1=itemView.findViewById(R.id.location1);
date1=itemView.findViewById(R.id.date1);
MainActivity.class
private void fetchInPro() {
RetrofitInterface jsonPostService = ServiceGenerator.createService(RetrofitInterface.class, "http://littletreasure.org.in/");
Call<InProgress_Response> call = jsonPostService.postRawJSON1();
call.enqueue(new Callback<InProgress_Response>() {
@Override
public void onResponse(Call<InProgress_Response> call, Response<InProgress_Response> response) {
if (response.isSuccessful()) {
proDialog.cancel();
List<Data_Inprogress> datumList1 = response.body().getData();
/*for (int i = 0; i < datumList.size(); i++) {
datumList.add(response.body().getData().get(i));
}*/
if (getActivity()!=null){
proDialog.cancel();
inProgress_adapter = new InProgress_Adapter(getContext(),datumList1);
recyclerView1.setLayoutManager(new LinearLayoutManager(getContext(), LinearLayoutManager.VERTICAL, false));
//recyclerView.setHasFixedSize(true);
//recyclerView.notify();
recyclerView1.setAdapter(inProgress_adapter);
}
}
}
这是我的回复
{
"status": "Success",
"message": "10 results found.",
"data": [
{
"work_order_id": 1,
"description": "Desc-1",
"locaion": "Locaion-1",
"date": "0-01-2020",
"duration": "1 days",
"user_name": "User name-1",
"user_address": "User address-1",
"payment_details": [
{
"amount": 0,
"date": "0-01-2020",
"payment_method": "Cash",
"balance": 0
}
]
},
{
"work_order_id": 2,
"description": "Desc-2",
"locaion": "Locaion-2",
"date": "1-01-2020",
"duration": "2 days",
"user_name": "User name-2",
"user_address": "User address-2",
"payment_details": [
{
"amount": 1,
"date": "1-01-2020",
"payment_method": "Cash",
"balance": 2
}
]
},
{
"work_order_id": 3,
"description": "Desc-3",
"locaion": "Locaion-3",
"date": "2-01-2020",
"duration": "3 days",
"user_name": "User name-3",
"user_address": "User address-3",
"payment_details": [
{
"amount": 2,
"date": "2-01-2020",
"payment_method": "Cash",
"balance": 4
}
]
},
{
"work_order_id": 4,
"description": "Desc-4",
"locaion": "Locaion-4",
"date": "3-01-2020",
"duration": "4 days",
"user_name": "User name-4",
"user_address": "User address-4",
"payment_details": [
{
"amount": 3,
"date": "3-01-2020",
"payment_method": "Cash",
"balance": 6
}
]
},
{
"work_order_id": 5,
"description": "Desc-5",
"locaion": "Locaion-5",
"date": "4-01-2020",
"duration": "5 days",
"user_name": "User name-5",
"user_address": "User address-5",
"payment_details": [
{
"amount": 4,
"date": "4-01-2020",
"payment_method": "Cash",
"balance": 8
}
]
},
{
"work_order_id": 6,
"description": "Desc-6",
"locaion": "Locaion-6",
"date": "5-01-2020",
"duration": "6 days",
"user_name": "User name-6",
"user_address": "User address-6",
"payment_details": [
{
"amount": 5,
"date": "5-01-2020",
"payment_method": "Cash",
"balance": 10
}
]
},
{
"work_order_id": 7,
"description": "Desc-7",
"locaion": "Locaion-7",
"date": "6-01-2020",
"duration": "7 days",
"user_name": "User name-7",
"user_address": "User address-7",
"payment_details": [
{
"amount": 6,
"date": "6-01-2020",
"payment_method": "Cash",
"balance": 12
}
]
}
]
}
这是我的 InProgress_Response
public class InProgress_Response {
private String status;
private String message;
/*data list of response*/
private List<Data_Inprogress> data=null;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<Data_Inprogress> getData() {
return data;
}
public void setData(List<Data_Inprogress> data) {
this.data = data;
}
}
这是我的 Data_Inprogress
public class Data_Inprogress {
private String description;
private Integer work_order_id;
private String locaion;
private String date;
private String duration;
private String user_name;
private String user_address;
@SerializedName("payment_details")
@Expose
private List<Payment_Inprogress> paymentDetails=null;
public List<Payment_Inprogress> getPaymentDetails() {
return paymentDetails;
}
public void setPaymentDetails(List<Payment_Inprogress> paymentDetails) {
this.paymentDetails = paymentDetails;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getWork_order_id() {
return work_order_id;
}
public void setWork_order_id(int work_order_id) {
this.work_order_id = work_order_id;
}
public String getLocaion() {
return locaion;
}
public void setLocaion(String locaion) {
this.locaion = locaion;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getUser_name() {
return user_name;
}
public void setUser_name(String user_name) {
this.user_name = user_name;
}
public String getUser_address() {
return user_address;
}
public void setUser_address(String user_address) {
this.user_address = user_address;
}
}
最佳答案
你可以像这样访问值
@Override
public void onBindViewHolder(@NonNull InProgressViewHolder holder, int i) {
holder.location1.setText(modelRecyclerArrayList.get(i).getLocaion());
holder.date1.setText(modelRecyclerArrayList.get(i).getDate());
holder.duration1.setText(modelRecyclerArrayList.get(i).getDuration());
holder.username1.setText(modelRecyclerArrayList.get(i).getUser_name());
holder.workerid1.setText(String.valueOf(modelRecyclerArrayList.get(i).getWork_order_id()));
holder.description1.setText(modelRecyclerArrayList.get(i).getDescription());
holder.useraddress1.setText(modelRecyclerArrayList.get(i).getUser_address());
// here how you access the values, here method name is based on convention, change with your get method name if different
holder.tvamt.setText(modelRecyclerArrayList.get(i).getPaymentDetails().get(0).getAmount());
holder.tvdt.setText(modelRecyclerArrayList.get(i).getPaymentDetails().get(0).getDate());
holder.tvcash.setText(modelRecyclerArrayList.get(i).getPaymentDetails().get(0).getPaymentMethod());
holder.tvbal.setText(modelRecyclerArrayList.get(i).getPaymentDetails().get(0).getBalance());
}
此处假设您的一系列付款详细信息只有一个对象(正如您在回复中向我们展示的那样)
关于android - 无法使用改造解析对象内部的 jsonarray 的 jsonarray?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60069732/
这是我的测试用例。 http://tobeythorn.com/isi/dummy2.svg http://tobeythorn.com/isi/isitest.html 如果我自己打开 svg,内部
这是我的测试用例。 http://tobeythorn.com/isi/dummy2.svg http://tobeythorn.com/isi/isitest.html 如果我自己打开 svg,内部
我正在尝试做类似的事情: SELECT SUM( CASE WHEN ( AND EXISTS(SELECT 1
我想问如何在外部 ng-repeat 内部正确使用内部 ng-repeat: 这意味着你想使用这样的东西: {{milestone.id}} {{
我希望在 wordpress 的仪表板内编辑 css 样式并且如果可能的话不必编辑 php 文件。 我知道至少可以编辑一些属性,所以我希望我可以直接在仪表板中编辑所有属性。 更具体地说如何更改自定义类
我在安装在 windows10 上的 vmware 中的 Ubuntu 上安装了伪分布式独立 hadoop 版本。 我从网上下载了一个文件,复制到ubuntu本地目录/lab/data 我在 ubun
我有一个如下所示的 WHERE 语句: WHERE ((@Value1 IS NULL AND [value1_id] IS NULL) OR [value1_id] = ISNULL(@Va
我有一个如下所示的 WHERE 语句: WHERE ((@Value1 IS NULL AND [value1_id] IS NULL) OR [value1_id] = ISNULL(@Va
在我的一些测试帮助程序代码中,我有一个名为 FakeDbSet(Of T) 的 IDbSet(Of T) 实现,它模拟了许多 EF 行为,但没有实际的数据库。我将类声明为 Friend ,因为我想强制
我正在寻找 Cassandra/CQL 的常见 SQL 习语 INSERT INTO ... SELECT ... FROM ... 的表亲。并且一直无法找到任何以编程方式或在 CQL 中执行此类操作
如何防止内部 while 循环无限运行?问题是,如果没有外部 while 循环,内部循环将毫无问题地运行。我知道它必须对外循环执行某些操作,但我无法弄清楚是什么导致了问题。 import java.u
我正在努力学习更多有关 C++ 的知识,但在国际象棋程序中遇到了一些代码,需要帮助才能理解。我有一个 union ,例如: union b_union { Bitboard b; st
这是我项目网页中的代码片段。这里我想显示用户选择的类别,然后想显示属于该类别的主题。在那里,用户可以拥有多个类别,这没有问题。我可以在第一个 while 循环中打印所有这些类别。问题是当我尝试打印主题
我想知道如何在 swing 中显示内部框架。这意味着,当需要 JFrame 时,通常我所做的是, new MyJFrame().setVisible(true); 假设之前的表单也应该显示。当显示这个
我最近发现了一些有趣的行为,这让我想知道对象如何知道存在哪些全局变量。例如,假设我有一个文件“test.py”: globalVar = 1 toDelete = 2 class Test(objec
我知道它已经在这里得到回答: google maps drag and drop objects into google maps from outside the Map ,但这并不完全是我所需要的
我目前正在学习Javascript DOM和innerHTML,发现在理解innerHTML方面存在一些问题。 这是我的代码:http://jsfiddle.net/hphchan/bfjx1w70/
我构建了一个布局如下的库: lib/ private_class_impl.cc private_class_decl.h public_class_impl.cc include/
我有一个使用 bootstrap 3 的组合 wordpress 网站。它基本上是一个图像网格。当屏幕展开时,它会从三列变为四列。移动时它是一列。 我想出了如何调整图像的顶部和底部边距,但我希望图像的
我正在试用 MSP-EXP430G2 的教程程序,使用 Code Composer Studio 使 LED 闪烁。最初,它有一个闪烁的无限循环: for(;;) // This emp
我是一名优秀的程序员,十分优秀!