我需要通过提供用户输入ID从json数据中检索值 [英] i need to retrieve values from json data by giving a user input ID
本文介绍了我需要通过提供用户输入ID从json数据中检索值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public void onSuccess(String response)
{
try{
JSONObject obj=new JSONObject(response);
if(obj!=null){
Toast.makeText(getApplicationContext(), response, Toast.LENGTH_LONG).show();
JSONArray data=obj.getJSONArray("RetrieveSupplierRegistrationDetailsResult");
details=obj.getJSONArray(TAG_RESULT);
for(int i=0;i<data.length();i++)
{
JSONObject c = data.getJSONObject(i);
if(c.getString("iSupplierID")!="0")
{
String SUPPLIER_NAME = c.getString(TAG_NAME);
String PRIMARY_SERVICE_CATEGORY = c.getString(TAG_PRIMARY);
String SECONDARY_SERVICE_CATEGORY = c.getString(TAG_SECONDARY);
HashMap<String, String> list = new HashMap<String, String>();
list.put(TAG_NAME, SUPPLIER_NAME);
list.put(TAG_PRIMARY, PRIMARY_SERVICE_CATEGORY);
list.put(TAG_SECONDARY, SECONDARY_SERVICE_CATEGORY);
detailList.add(list);
lv=(ListView) findViewById(R.id.listView1);
ListAdapter adapter = new SimpleAdapter(SupplierDetails.this, detailList,R.layout.list_view, new String[]
{ TAG_NAME, TAG_PRIMARY,TAG_SECONDARY }, new int[] { R.id.name,R.id.primary, R.id.secondary });
// Toast.makeText(getApplicationContext(), SUPPLIER_NAME, Toast.LENGTH_SHORT).show();
lv.setAdapter(adapter);
}
}
}
}catch(JSONException e){
e.printStackTrace();
}
推荐答案
您是否告知列表视图数据已更改?
Do you inform the listview the data has changed ?
lv.notifyDataSetChanged();
如果没有尝试在填充循环结束
/ Darren
If not try adding doing that at the end of the populate loop
/Darren
这篇关于我需要通过提供用户输入ID从json数据中检索值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文