0
我有一個arraylist包含用戶ids.I想要檢查數據庫中的ID,並必須通過凌雲從mysql中獲取詳細信息,並希望按升序顯示listview中的詳細信息的id.How我可以實現這一目標?在arraylist中以列表形式打印數據
ArrayList<String> absenceids=new ArrayList<>();
Iterator<String> itr=absenceids.iterator();
while (itr.hasNext()){
getdetails(itr.next());
}
我getdetails()方法:
StringRequest stringRequest = new StringRequest(Request.Method.POST,URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONArray jsonResponse = new JSONObject(response).getJSONArray("Android");
int i=jsonResponse.length();
for(int j=0;j<i;j++) {
JSONObject jsonChildNode = jsonResponse.getJSONObject(j);
String user_id = jsonChildNode.optString("uid").toString();
String rollnum = jsonChildNode.optString("rollnum").toString();
String name = jsonChildNode.optString("name").toString();
/* MA_id.add(rollnum);
Collections.sort(MA_id);
Toast.makeText(AttendenceSave.this, MA_id.toString(), Toast.LENGTH_SHORT).show();
MA_name.add(name);
Collections.sort(MA_name);*/
HashMap<String, String> contact = new HashMap<>();
contact.put("uid",user_id);
contact.put("rollnum",rollnum);
contact.put("name", name);
Listdetails.add(contact);
//CustomListAdapter2 adapter=new CustomListAdapter2(AttendenceSave.this,MA_id,MA_name);
ListAdapter adapter = new SimpleAdapter(AttendenceSave.this,Listdetails, R.layout.absenteeslayout, new String[]{"rollnum", "name"}, new int[]{R.id.abroll, R.id.abname});
absentees_list.setAdapter(adapter);
Utility.setListViewHeightBasedOnChildren(absentees_list);
你到目前爲止嘗試過什麼? –
請顯示你的努力 – Piyush
你能證明你已經嘗試了什麼,是什麼問題? – UltimateDevil