我有以下如何通过从凌空响应变量
ImageView mImageView;
mTxtDisplay = (TextView) findViewById(R.id.txtDisplay);
String url = "http://my-json-feed";
String xSession = "";
JsonObjectRequest jsObjRequest = new JsonObjectRequest
(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
/*
{
"message": "Session created",
"session": "d4f7d26799c720eb6b09daa97a1b7e64",
"result": {
"id": "331339814848696320",
"name": "Administrator",
"email": "[email protected]",
"username": "admin"
}
}
*/
xSession = response.getString("session");
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
// TODO Auto-generated method stub
}
});
// Access the RequestQueue through your singleton class.
MySingleton.getInstance(this).addToRequestQueue(jsObjRequest);
的响应,我可以看到response.getString(“会议”)的价值,但没有填充XSESSION? 为什么xSession没有被填充?请帮忙!
可以显示响应jsonobject? –
您声明了xsession,但为xSession分配了值。 xSession在哪里宣布? – Sharj
对不起,兄弟我在这里输入“xSession”在这个问题上声明xsession,但是在代码中它总是“xSession”。 –