Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Java
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    AsyncHttpClient usercheck=new AsyncHttpClient();
    usercheck.get("http://WebServices.SuppliersMax.com/SuppliersMax.svc/PopulateSuppliersList", new AsyncHttpResponseHandler(){
        public void onSuccess(String response){
            try {
                JSONObject obj3 = new JSONObject(response);
                
                JSONArray jsonArray3 = obj3.getJSONArray("PopulateSuppliersList");
                name=obj3.getJSONArray("PopulateSuppliersList");
                int length3 = jsonArray3.length();
                if(iActivationID!=0)
                {
                    List<string> listContents3 = new ArrayList<string>(length3);
                    for (int i = 0; i < length3; i++)
                    {
                        JSONObject user3 = jsonArray3.getJSONObject(i);
                        if(user3.getInt("ID")>=6)
                        listContents3.add(user3.getString("SUPPLIER_NAME"));
                        //  nm=name.getJSONObject(i);
                    }
                    
                    key = (ListView) findViewById(R.id.listView1);
                    key.setAdapter(new ArrayAdapter<string>(MainActivity.this, android.R.layout.simple_list_item_1, listContents3));
                
                }    
            } catch (JSONException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        key.setOnItemClickListener(new OnItemClickListener() {
        
            @Override
            public void onItemClick(AdapterView, int position, long id) {
                // TODO Auto-generated method stub
                try{
                    String iActivationID=name.getJSONObject(position).getString("ID");
                    RequestParams params = new RequestParams();
                    
                    
                    
                    params.put("iActivationID",iActivationID);
                    //postMyShoppingPreferenceItem(params);
                }catch(JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

    });
Posted
Updated 23-Mar-15 2:26am
v4
Comments
ZurdoDev 23-Mar-15 7:49am    
And the error is?
Rahul Ramakrishnan 23-Mar-15 7:59am    
java null pointer exception
handler.dispatch message
Richard MacCutchan 23-Mar-15 8:26am    
You need to get your debugger running and see what is causing the null pointer.

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