我已经使用ListView来填充JSON Data.With在List中我有像
这样的结构的ListView
* TextView
* TextView
* ListView
我可以填充外部listView
和textView
,但无法填充innerList.So
我在ListView
的地方使用线性布局。{the { {1}}与列表的工作一样使用吗?
费用等级
LinearLayout
CustomFeeListStudentAdapter
private void getUsersListData() {
String URL = Navigation_URL + "?id=" + master_id;
StringRequest stringRequest = new StringRequest(Request.Method.GET, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
ArrayList<StudentFeeInformation> student_list = new ArrayList<>();
ArrayList<StudentFeeInformation> student_list_description = new ArrayList<>();
JSONArray jArray = new JSONArray(response);
// studentFeeInformation = new StudentFeeInformation(response);
for (int i = 0; i < jArray.length(); i++) {
JSONObject jsonObject = jArray.getJSONObject(i);
status = jsonObject.getString("Status");
DateofReceiptIssued = jsonObject.getString("DateOfReciept").substring(0, 10);
ReceiptNumber = jsonObject.getString("RecieptNo");
FeeReceivedDate = jsonObject.getString("recivedDate").substring(0, 10);
String Description = jsonObject.getString("Description");
JSONArray jArray1 = new JSONArray(Description);
// JSONArray descriptionArray = jsonObject.getJSONArray("Description");
for (int j = 0; j < jArray1.length(); j++) {
JSONObject jsonObjectinner = jArray1.getJSONObject(j);
Descriptionlist = jsonObjectinner.getString("des");
Amount = jsonObjectinner.getString("Amount");
student_list.add(new StudentFeeInformation(status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate, Descriptionlist, Amount));
}
//student_list.add(new StudentFeeInformation(status, DateofReceiptIssued, ReceiptNumber, FeeReceivedDate, Descriptionlist, Amount));
}
System.out.println("student_list size:" + student_list.size());
CustomFeeListStudentAdapter customFeeListStudentAdapter = new CustomFeeListStudentAdapter(getActivity(), student_list);
listViewfees.setAdapter(customFeeListStudentAdapter);
} catch (JSONException e) {
System.out.println("This is not good");
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// Toast.makeText(view.Fee.this, error.toString(), Toast.LENGTH_LONG).show();
}
}) {
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String, String> headers = new HashMap<String, String>();
return headers;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(getContext());
requestQueue.add(stringRequest);
}
StudentFeeInformation类
public class CustomFeeListStudentAdapter extends BaseAdapter {
LinearLayout receipt1, receipt2, receipt3, receipt4;
LinearLayout receipt1detail, receipt2detail, receipt3detail, receipt4detail;
Context mContext;
ArrayList<StudentFeeInformation> student_list;
String TAG = "HomeTab_adapter";
public CustomFeeListStudentAdapter(Context mContext, ArrayList<StudentFeeInformation> student_list) {
super();
this.mContext = mContext;
this.student_list = student_list;
}
@Override
public int getCount() {
return student_list.size();
}
@Override
public Object getItem(int arg0) {
return arg0;
}
@Override
public long getItemId(int arg0) {
return arg0;
}
@Override
public View getView(final int postion, View convertView, ViewGroup parent) {
final Holder viewHolder;
if (convertView == null) {
// inflate the layout
LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.fragment_fee, parent, false);
// well set up the ViewHolder
viewHolder = new Holder();
viewHolder.student_profile_fee_status = (TextView) convertView.findViewById(R.id.student_profile_fee_status);
viewHolder.student_profile_ReceiptIssuedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedDate);
viewHolder.student_profile_ReceiptIssuedNumber = (TextView) convertView.findViewById(R.id.student_profile_fee_ReceiptIssuedNumber);
viewHolder.student_profile_FeeReceivedDate = (TextView) convertView.findViewById(R.id.student_profile_fee_FeeReceiptDate);
viewHolder.student_profile_Fee_Amount = (TextView) convertView.findViewById(R.id.student_profile_fee_amount);
viewHolder.student_profile_Fee_Description = (TextView) convertView.findViewById(R.id.student_profile_fee_description);
} else {
// we've just avoided calling findViewById() on resource everytime
// just use the viewHolder
viewHolder = (Holder) convertView.getTag();
}
viewHolder.student_profile_fee_status.setText(student_list.get(postion).getStatus());
viewHolder.student_profile_ReceiptIssuedDate.setText(student_list.get(postion).getReceiptIssuedDate());
viewHolder.student_profile_ReceiptIssuedNumber.setText(student_list.get(postion).getReceiptIssuedNumber());
viewHolder.student_profile_FeeReceivedDate.setText(student_list.get(postion).getFeeReceivedDate());
viewHolder.student_profile_Fee_Amount.setText(student_list.get(postion).getAmount());
viewHolder.student_profile_Fee_Description.setText(student_list.get(postion).getFeeDescription());
convertView.setTag(viewHolder);
return convertView;
}
class Holder {
TextView student_profile_fee_status;
TextView student_profile_ReceiptIssuedDate;
TextView student_profile_ReceiptIssuedNumber;
TextView student_profile_FeeReceivedDate;
TextView student_profile_Fee_Amount;
TextView student_profile_Fee_Description;
}
frgament_fee
public class StudentFeeInformation implements Serializable {
public String Status;
public String ReceiptIssuedDate;
public String ReceiptIssuedNumber;
public String FeeReceivedDate;
public String FeeDescription;
public String Amount;
public StudentFeeInformation(String status, String ReceiptissuedDate, String ReceiptissuedNumber, String FeereceivedDate,String feeDescription, String amount) {
Status = status;
ReceiptIssuedDate = ReceiptissuedDate;
ReceiptIssuedNumber = ReceiptissuedNumber;
FeeReceivedDate = FeereceivedDate;
FeeDescription = feeDescription;
Amount = amount;
}
public String getStatus() {
return Status;
}
public void setStatus(String status) {
Status = status;
}
public String getReceiptIssuedDate() {
return ReceiptIssuedDate;
}
public void setReceiptIssuedDate(String receiptIssuedDate) {
ReceiptIssuedDate = receiptIssuedDate;
}
public String getReceiptIssuedNumber() {
return ReceiptIssuedNumber;
}
public void setReceiptIssuedNumber(String receiptIssuedNumber) {
ReceiptIssuedNumber = receiptIssuedNumber;
}
public String getFeeReceivedDate() {
return FeeReceivedDate;
}
public void setFeeReceivedDate(String feeReceivedDate) {
FeeReceivedDate = feeReceivedDate;
}
public String getFeeDescription() {
return FeeDescription;
}
public void setFeeDescription(String feeDescription) {
FeeDescription = feeDescription;
}
public String getAmount() {
return Amount;
}
public void setAmount(String amount) {
Amount = amount;
}
}
我希望描述的输出在同一个列表中。如何通过linearlayout实现这一点?