做个笔记 androuid 遍历一个 view 下面的子view
// 保存 btnSaveRout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub // lineBox 下面的proBox下面所有的 addEdit String JsonString = ""; JSONArray jsonarray = new JSONArray(); for (int k = 0; k < lineBox.getChildCount(); k++) { LinearLayout layout = (LinearLayout) lineBox.getChildAt(k); for (int i = 0; i < layout.getChildCount(); i++) { View viewChildren = layout.getChildAt(i); if (viewChildren instanceof EditText) { EditText edt = (EditText) viewChildren; // 总json对象 JSONObject jsonObjs = new JSONObject(); String Point = (String) edt.getTag(); String StopName = edt.getText().toString(); try { jsonObjs.put("point", Point); jsonObjs.put("pointgps", Point); jsonObjs.put("text", StopName); jsonarray.put(jsonObjs); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } Toast.makeText(getApplicationContext(), jsonarray.toString(), Toast.LENGTH_SHORT).show(); } }); }