我試圖將我的應用程序連接到服務器,但出現錯誤。請幫忙!錯誤:(54,91)錯誤:不兼容的類型:int不能轉換爲字符串
我試圖用凌空庫到服務器的連接我的應用程序,但每當我嘗試運行我的代碼,我得到以下錯誤
incompatible types: int cannot be converted to String
我試圖從字符串改變爲int,但它沒沒有幫助!
show.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest(Request.Method.POST, **<-------------error here**
showUrl, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONArray student = response.getJSONArray("student");
for (int i=0;i<student.length();i++){
JSONObject students = student.getJSONObject(i);
String firstname = students.getString("firstname");
String lastname = students.getString("lastname");
String age = students.getString("age");
result.append(firstname+""+lastname+""+age+""+"\n");
}
result.append("==\n");
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
requestQueue.add(jsonObjectRequest);
}
});
}
}
你的轉換在哪裏? int是那個年齡? –
我試過這樣做 int age = students.getInt(「age」); 但它沒有幫助! –
@AnujGajbhiye你可以分享你的'JSON'迴應嗎? –