サーバーからのデータを表示したいと思います。結果データが表示されます。[get(0);インデックス(0)、価格:3800]。私はアンドロイドでlistviewですべてのデータを表示したいと思います。私は、BaseAdapter、CustomAdapterを使用します。ここで予約オブジェクトのAPI。アンドロイドのListViewでデータを表示する方法は?
[
{
"order_id": 13,
"booking_person": 2,
"booking_datetime": "2016-07-01 22:30:00",
"total_amount": 2100,
"order_details": [
{
"id": 20,
"order_id": 13,
"qty": 1,
"price": 3800,
"sub_total": 3800,
},
{
"id": 21,
"order_id": 13,
"qty": 1,
"price": 3250,
"sub_total": 3250,,
},
{
"id": 124,
"order_id": 13,
"qty": 1,
"price": 2100,
"sub_total": 2100,
}
]
},
]
BookingActivity.java
Bundle bundle = getIntent().getExtras();
Booking booking = new Gson().fromJson(bundle.getString("Booking"), Booking.class);
List<Booking> bookingList = new ArrayList<Booking>();
bookingList.add(booking);
BookingDetailAdapter adapter = new BookingDetailAdapter(BookingActivity.this, bookingList);
lv.setAdapter(adapter);
BookingDetailAdapter.clsas
@Override
public View getView(int position, View convertView, ViewGroup parent){
Booking booking = list.get(position);
for (int i = 0; i < list.size(); i++) {
holder.textView.setText(list.get(i).getOrderDetail().get(0).getPrice().toString());
}
return rowView;
}
ディディの? – DKV
ビューrowView rowView = inflater.inflate(R.layout.activity_listview、null); –
あなたは貼り付けアダプタクラス – DKV