Click here to Skip to main content
15,891,934 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Java
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();
		}
Posted
Comments
Rahul Ramakrishnan 31-Mar-15 1:21am    
i am getting response from json but the listview is empty
Afzaal Ahmad Zeeshan 31-Mar-15 1:42am    
In that case you can debug your application to see why your ListView is empty.

1 solution

Do you inform the listview the data has changed ?

Java
lv.notifyDataSetChanged();


If not try adding doing that at the end of the populate loop

/Darren
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900