JSON을 통해 내 안드로이드 응용 프로그램에 아래 나와있는 PHP 파일의 출력을 얻으려고하고 있지만 내 안드로이드 응용 프로그램의 첫 번째 항목 만 가져오고 있습니다. 뿐만 아니라 내가하지만 난 단지 첫번째 출력되지만 출력의 휴식을 얻을 수 있어요 수있는 다음 단계를 수행하면발리를 사용하여 mysql에서 JSON을 통해 여러 행을 얻는 방법
private void getData() {
String id = editTextId.getText().toString().trim();
if (id.equals("")) {
Toast.makeText(this, "Please enter an id", Toast.LENGTH_LONG).show();
return;
}
loading = ProgressDialog.show(this,"Please wait...","Fetching...",false,false);
String url = Constants.DATA_URL+editTextId.getText().toString().trim();
StringRequest stringRequest = new StringRequest(url, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
loading.dismiss();
showJSON(response);
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(OrderHistory.this,error.getMessage().toString(),Toast.LENGTH_LONG).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
private void showJSON(String response){
String name="";
String address="";
String vc = "";
try {
JSONObject jsonObject = new JSONObject(response);
JSONArray result = jsonObject.getJSONArray(Constants.JSON_ARRAY);
JSONObject collegeData = result.getJSONObject(0);
name = collegeData.getString(Constants.KEY_NAME);
address = collegeData.getString(Constants.KEY_ADDRESS);
vc = collegeData.getString(Constants.KEY_VC);
} catch (JSONException e) {
e.printStackTrace();
}
textViewResult.setText("Name:\t"+name+"\nAddress:\t" +address+ "\nVice Chancellor:\t"+ vc);
}
감사 없애! (jsonlint.com을 통해 테스트 한) 유효한 JSON을 보내고 있지만 앱에서는 여전히 단일 출력 만 볼 수 있습니다. ( –
그러면 'customerEmail =' ". $ customerEmail." ' "'이있는 행이 하나만 있습니다. – RiggsFolly
DB에 81 행이 있음을 확인했습니다. –