Android JSON响应';要使用recylerView显示的零件

Android JSON响应';要使用recylerView显示的零件,android,json,cardview,Android,Json,Cardview,我需要显示JSON响应中的成分和度量的列表。我知道如何从整个响应中获取“类别”和“区域”。尽管如此,我不知道如何获取成分和度量(作为我的recylerView的一部分,包括类别、区域等)。我需要在不同的CardView中显示包含所有成分和尺寸的食谱 我已经发布了一段json响应和我的代码。 多谢各位 这是JSON响应 {"meals":[{"idMeal":"52956", "strMeal":"Chicken Congee", "strCategory":"Chicken", "strArea

我需要显示JSON响应中的成分和度量的列表。我知道如何从整个响应中获取“类别”和“区域”。尽管如此,我不知道如何获取成分和度量(作为我的recylerView的一部分,包括类别、区域等)。我需要在不同的CardView中显示包含所有成分和尺寸的食谱

我已经发布了一段json响应和我的代码。 多谢各位

这是JSON响应

{"meals":[{"idMeal":"52956",
"strMeal":"Chicken Congee",
"strCategory":"Chicken",
"strArea":"Chinese",
"strInstructions":"STEP 1 - MARINATING THE CHICKEN\r\nIn a bowl, add chicken, salt, white pepper, ginger juice and then mix it together well.\r\nSet the chicken aside.\r\nSTEP 2 - RINSE THE WHITE RICE\r\nRinse the rice in a metal bowl or pot a couple times and then drain the water.\r\nSTEP 2 - BOILING THE WHITE RICE\r\nNext add 8 cups of water and then set the stove on high heat until it is boiling. Once rice porridge starts to boil, set the stove on low heat and then stir it once every 8-10 minutes for around 20-25 minutes.\r\nAfter 25 minutes, this is optional but you can add a little bit more water to make rice porridge to make it less thick or to your preference.\r\nNext add the marinated chicken to the rice porridge and leave the stove on low heat for another 10 minutes.\r\nAfter an additional 10 minutes add the green onions, sliced ginger, 1 pinch of salt, 1 pinch of white pepper and stir for 10 seconds.\r\nServe the rice porridge in a bowl\r\nOptional: add Coriander on top of the rice porridge.",
"strMealThumb":"https:\/\/www.themealdb.com\/images\/media\/meals\/1529446352.jpg","strTags":null,
"strYoutube":"https:\/\/www.youtube.com\/watch?v=kqEfk801E94",

"strIngredient1":"Chicken","strIngredient2":"Salt","strIngredient3":"Pepper","strIngredient4":"Ginger Cordial","strIngredient5":"Ginger","strIngredient6":"Spring Onions","strIngredient7":"Rice","strIngredient8":"Water","strIngredient9":"Coriander","strIngredient10":"","strIngredient11":"","strIngredient12":"","strIngredient13":"","strIngredient14":"","strIngredient15":"","strIngredient16":"","strIngredient17":"","strIngredient18":"","strIngredient19":"","strIngredient20":"",

"strMeasure1":"8 oz ","strMeasure2":"pinch","strMeasure3":"pinch","strMeasure4":"1 tsp ","strMeasure5":"1 tsp ","strMeasure6":"1 tbs","strMeasure7":"1\/2 cup ","strMeasure8":"8 cups ","strMeasure9":"2 oz ","strMeasure10":"","strMeasure11":"","strMeasure12":"","strMeasure13":"","strMeasure14":"","strMeasure15":"","strMeasure16":"","strMeasure17":"","strMeasure18":"","strMeasure19":"","strMeasure20":"",
"strSource":"https:\/\/sueandgambo.com\/pages\/chicken-congee",
"dateModified":null},
{"idMeal":"52955",
"strMeal":"Egg Drop Soup",
"strCategory":"Vegetarian",
"strArea":"Chinese",
"strInstructions":"In a wok add chicken broth and wait for it to boil.\r\nNext add salt, sugar, white pepper, sesame seed oil.\r\nWhen the chicken broth is boiling add the vegetables to the wok.\r\nTo thicken the sauce, whisk together 1 Tablespoon of cornstarch and 2 Tablespoon of water in a bowl and slowly add to your soup until it's the right thickness.\r\nNext add 1 egg slightly beaten with a knife or fork and add it to the soup slowly and stir for 8 seconds\r\nServe the soup in a bowl and add the green onions on top.",
"strMealThumb":"https:\/\/www.themealdb.com\/images\/media\/meals\/1529446137.jpg",
"strTags":"Soup,Baking,Calorific",
"strYoutube":"https:\/\/www.youtube.com\/watch?v=9XpzHm9QpZg",
"strIngredient1":"Chicken Stock","strIngredient2":"Salt","strIngredient3":"Sugar","strIngredient4":"Pepper","strIngredient5":"Sesame Seed Oil","strIngredient6":"Peas","strIngredient7":"Mushrooms","strIngredient8":"Cornstarch","strIngredient9":"Water","strIngredient10":"Spring Onions","strIngredient11":"","strIngredient12":"","strIngredient13":"","strIngredient14":"","strIngredient15":"","strIngredient16":"","strIngredient17":"","strIngredient18":"","strIngredient19":"","strIngredient20":"",
"strMeasure1":"3 cups ","strMeasure2":"1\/4 tsp","strMeasure3":"1\/4 tsp","strMeasure4":"pinch","strMeasure5":"1 tsp ","strMeasure6":"1\/3 cup","strMeasure7":"1\/3 cup","strMeasure8":"1 tbs","strMeasure9":"2 tbs","strMeasure10":"1\/4 cup","strMeasure11":"","strMeasure12":"","strMeasure13":"","strMeasure14":"","strMeasure15":"","strMeasure16":"","strMeasure17":"","strMeasure18":"","strMeasure19":"","strMeasure20":"","strSource":"https:\/\/sueandgambo.com\/pages\/egg-drop-soup","dateModified":null}
这是我从JSON响应中获取内容的方法,该响应似乎不适用于INMGREDIENTS

我尝试了两个循环,但没有成功

private void loadRecylerViewData () {

    StringRequest stringRequest = new StringRequest(Request.Method.GET, URL_DATA,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {
                        JSONObject jsonObject = new JSONObject(response);
                        JSONArray jsonArray = jsonObject.getJSONArray("meals");
                        String hello;
                        String ing = "strIngredient";
                        ArrayList<String> listIng = new ArrayList<>();

                        Log.e(" " + jsonArray.length(), "error");
                        for (int i = 0; i < (jsonArray.length()); i++) {

                            JSONObject o = jsonArray.getJSONObject(i);


                             for (int n = 1; n <= 20; n++)
                            {

                                hello = ing.concat(Integer.toString(n));
                                listIng.add( o.getString(hello));

                            }
                            element e = new element(o.getString("strCategory"), o.getString("strMealThumb "),
                                    listIng);
                            elementList.add(e);
                        }


                        adapter = new recylerAdapter(elementList, getApplicationContext());
                        recyclerView.setAdapter(adapter);


                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
private void loadRecylerViewData(){
StringRequest StringRequest=新的StringRequest(Request.Method.GET,URL\u数据,
新的Response.Listener(){
@凌驾
公共void onResponse(字符串响应){
试一试{
JSONObject JSONObject=新JSONObject(响应);
JSONArray JSONArray=jsonObject.getJSONArray(“膳食”);
串你好;
字符串ing=“StringCredit”;
ArrayList listIng=新的ArrayList();
Log.e(“+jsonArray.length(),“error”);
对于(int i=0;i<(jsonArray.length());i++){
JSONObject o=jsonArray.getJSONObject(i);

对于(int n=1;n它会崩溃吗?你可以尝试使用断点并调试正在发生的事情。什么错误没有错误,应用程序也不会崩溃。我只是不知道如何在一个配方中获得所有成分和度量值,以及所有其他成分(类别、区域等)