Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have created a Project in which i have acustom alertdialog box with 3 edit text and one button. On button Click it add my data to Recyclerview successfully and it's working fine.

Now i want to post the recyclerview data to server using volley Post method can any one help me out how can i do it i just need a idea how to send data of recyclerview(list of my Recyclerview) to server. I want to Post full list of objects in array to server.

what should i send to my parameters so that i Successful post the recyclerview data to my server.

I have Reached Almost there but i want all objects in my same ARRAY LIST DATA But i am getting Different Array List with different object(need All object in one Array list)

Need Output Like

 [{
    "movie_name":"trter",
    "movies_Add":"hgjhj90",
    "movie_no":"8787878787"
    }
    {
    "movie_name":"trter",
    "movies_Add":"hgjhj90",
    "movie_no":"8787878787"
    }
    {
    "movie_name":"trter",
    "movies_Add":"hgjhj90",
    "movie_no":"8787878787"
    }
    ]

Code of

 JSONArray movieArray = new JSONArray();
                for (int i = 0; i <= movieList.size(); i++) {
                    JSONObject movieObject = new JSONObject();
                    try {
                        movieObject.put("movie_name", "" + member_name);
                        movieObject.put("movies_Add", "" + member_adds);
                        movieObject.put("movie_no", "" + member_contacts);
                        movieArray.put(movieObject);
                    } catch (JSONException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
                String jsonStr = movieArray.toString();

                Log.i("jsonobj12", String.valueOf(movieArray));
                Log.i("jsonobj123", String.valueOf(movieList1.size()));

Log Data

2020-02-14 09:49:54.283 17587-17587/com.example.raid I/jsonobj12: [{"movie_name":"trter","movies_Add":"hgjhj90","movie_no":"8787878787"}]
2020-02-14 09:49:54.283 17587-17587/com.example.raid I/jsonobj123: 1
2020-02-14 09:50:03.381 17587-17587/com.example.raid I/jsonobj12: [{"movie_name":"tertre","movies_Add":"hgvjnbk99090","movie_no":"7687687868"}]
2020-02-14 09:50:03.381 17587-17587/com.example.raid I/jsonobj123: 2
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
199 views
Welcome To Ask or Share your Answers For Others

1 Answer

There are a few problems in your code I want to point out, maybe one of is fixing your problem. Identifying the real problem is hard, because you did not provide enough information:

  1. This loop for (int i = 0; i <= movieList.size(); i++) { iterates one time too often. Let's say your movieList has 3 elements, your loop will iterate for each i in (0,1,2,3) but your list only has the indices (0,1,2) as Arrays/Lists start with index 0. So you should use i < movieList.size() here.
  2. Are you sure you are adding the right items to your movieObject? movieObject.put("movie_name", "" + member_name); uses the variable member_name which is not updated within your loop, you probably need to use movieList.get(i).member_name or similar (please provide more information what exactly the movieList looks like). Same applies for the following two lines
  3. In your log you use movieList1 but in your loop you use movieList are you sure both lists are the same?

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...