我试图将我的应用程序连接到服务器,但出现错误。请帮忙!错误:(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'回应吗? –