【发布时间】:2018-05-02 03:04:39
【问题描述】:
我正在尝试在 ArrayList 对象上添加来自 MySQL 数据库的对象,但结果只给了我一行
我在我的ListView 上使用自定义适配器,我想我可以使用循环多个对象到ArrayList 对象但我失败了,请帮助我,
我的代码:
String driver_fullname = json.getString("driver_fullname");
String driver_phonenumber = json.getString("driver_phonenumber");
String plate_no = json.getString("plate_no");
String parking_name = json.getString("parking_name");
List<PaymentTiming_Items> getAllDiverDetails = new ArrayList<PaymentTiming_Items>();
PaymentTiming_Items timingItems = new PaymentTiming_Items();
timingItems.setPlateNo(plate_no);
timingItems.setParkingName(parking_name);
timingItems.setDriverFullName(driver_fullname);
getAllDiverDetails.add(timingItems); // store all drivers' info to
}
if (getAllDiverDetails.size() !=0) {
userList = new ArrayList<> (getAllDiverDetails);
listAdapter = new PaymentTiming_ListAdapter(getApplicationContext(), userList);
myList.setAdapter(listAdapter);
}
【问题讨论】:
-
你能添加自定义布局xml吗..检查它的高度是否“匹配当前”。如果它 match_parent 将其更改为 wrap_content
-
@Tomin B 自定义布局在自定义适配器中,我认为问题不是布局
-
添加如何加载多个数据。?代码中没有循环。
-
@Mohamed,我没有收到错误,问题是我的 json 生成了很多行,但我通过 ArrayList 在 ListView 上只得到了一行
-
我正在更新我的评论 - 添加用于加载多个数据的代码。
标签: java android mysql listview arraylist