Java 如何在android中从阵列中获取数据?

Java 如何在android中从阵列中获取数据?,java,android,arrays,arraylist,Java,Android,Arrays,Arraylist,我想从android中的数组中获取数据。我大声吼叫。告诉我如何在android中从该阵列获取数据。我从Parse得到这个数组 [ { "name": "ajino motto", "qty": 30, "unit": "Gms" }, { "name": "cobbige", "qty": 20, "unit": "Gms" }, { "name": "salt", "qty": 0, "unit": "

我想从android中的数组中获取数据。我大声吼叫。告诉我如何在android中从该阵列获取数据。我从Parse得到这个数组

[
  {
    "name": "ajino motto",
    "qty": 30,
    "unit": "Gms"
  },
  {
    "name": "cobbige",
    "qty": 20,
    "unit": "Gms"
  },
  {
    "name": "salt",
    "qty": 0,
    "unit": "Gms"
  }
]
这样试试

List<JSONObject> jsobj = new ArrayList<JSONObject>();

            jsobj = CommanClass.ParseObject_RecieptMaster
                    .getList(MainScreen.key_ingredientlist);

            for (int i = 0; i < jsobj.size(); i++) {
                Log.e("in the For loop ", ": : ::111111 : " + jsobj.get(i));

                JSONObject arr1 = new JSONObject((Map) jsobj.get(i)); // jsobj.get(i);
                Log.e("in the For loop ", ": : ::111111 : " + arr1);
                try {
                    Log.e("in the For loop ",
                            ": : ::111111 : " + arr1.getString("name"));

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }

它在我的应用程序中完成了工作。

如果您的数组来自字符串use Gson,则答案应该更详细。目前这是一个低质量的答案。
List<JSONObject> jsobj = new ArrayList<JSONObject>();

            jsobj = CommanClass.ParseObject_RecieptMaster
                    .getList(MainScreen.key_ingredientlist);

            for (int i = 0; i < jsobj.size(); i++) {
                Log.e("in the For loop ", ": : ::111111 : " + jsobj.get(i));

                JSONObject arr1 = new JSONObject((Map) jsobj.get(i)); // jsobj.get(i);
                Log.e("in the For loop ", ": : ::111111 : " + arr1);
                try {
                    Log.e("in the For loop ",
                            ": : ::111111 : " + arr1.getString("name"));

                } catch (JSONException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }