JSONArray无法添加Response方法

时间:2017-10-23 13:25:22

标签: java android android-intent

不适用于public void onResponse(JSONArray response)

public void sendRequest(){

    JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, request_url, null, new Response.Listener() {
        @Override
        public void onResponse(JSONArray response) {




            for(int i = 0; i < response.length(); i++){

                SliderUtils sliderUtils = new SliderUtils();

                try {
                    JSONObject jsonObject = response.getJSONObject(i);

                    sliderUtils.setSliderImageUrl(jsonObject.getString("image_url"));

                } catch (JSONException e) {
                    e.printStackTrace();
                }

                sliderImg.add(sliderUtils);
        }

2 个答案:

答案 0 :(得分:0)

Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setType("image/*");
startActivityForResult(photoPickerIntent, 1);

尝试以上代码

答案 1 :(得分:0)

Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT);
getIntent.setType("image/*");

Intent pickIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        pickIntent.setType("image/*");

/*Intent chooserIntent = Intent.createChooser(getIntent, "Select Image");
       chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[]{pickIntent});*/

startActivityForResult(
                Intent.createChooser(pickIntent, "Select Image"), PICK_IMAGE);

尝试使用此代码段,也尝试使用注释代码一次。