passing JSON object to another activity on list item click

前端 未结 3 1021
长发绾君心
长发绾君心 2021-01-28 18:02

I have a scenario here,i want to pass the desired json object on the list item click in my below activity

\"activity

3条回答
  •  忘掉有多难
    2021-01-28 18:05

    you can pass JsonObject from JsonArray according to ListView item clicked Position as:

    list.setOnItemClickListener(new OnItemClickListener() {
    
       public void onItemClick(AdapterView arg0, View arg1,
                        final int arg2, long arg3) {
             if(!jArray.isNull(arg2)){
               Intent intent = new Intent(context,Finaldeal.class);  
               intent.putExtra("deal", jArray.optJSONObject(arg2).toString());
               startActivity(intent);                                     
             }   
           }
    
        }); 
    

    currently you are passing json_data which always contain last JSONObject from JSONArray when for loop execution end

提交回复
热议问题