android display json object to listview

后端 未结 2 953
悲&欢浪女
悲&欢浪女 2021-01-16 08:38

This is the code I\'m working on:

   private final static String SERVICE_URI = \"http://restwebservice.com/test/Service.svc\";

StringEntity entity;
String          


        
2条回答
  •  情歌与酒
    2021-01-16 09:19

    this is what i did to generate listview from my json response, basically i wrote values from my jon response to adapter and set it to my list view

    try{
            jArray = new JSONArray(result);
            for(int i=0;i();
                for(int i=0;i(this, R.layout.listrow, planetList);
                    runOnUiThread(new Runnable() {
                        public void run() {
                            list.setAdapter(listAdapter);
                        }
                    });
                 }
                list.setOnItemClickListener(new OnItemClickListener() {  //where to put this piece of code???
    
                    public void onItemClick(AdapterView arg0, View arg1,
                            final int arg2, long arg3) {
    
                    Intent intent = new Intent(context,Finaldeal.class);  
                    intent.putExtra("deal", json_data.toString());
                    startActivity(intent);                                     
                    }
    
                }); 
    
    }
    catch(JSONException e){
            Log.e("log_tag", "Error parsing data "+e.toString());
    }
    

    you can also refer to question i asked here

    passing JSON object to another activity on list item click

提交回复
热议问题