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