我有一个带有textview的Listview。单击convertview后,将调用该方法:
private void getAmountFromItem() {
String url = "http://192.168.192.200/getAmountFromItem.php?amount_id=" + amountIDTest;
Log.e("URLUZ", "is " + url);
// making fresh volley request and getting json
JsonObjectRequest jsonReq = new JsonObjectRequest(Request.Method.GET,
url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
VolleyLog.d(TAG, "Response: " + response.toString());
if (response != null) {
try {
JSONArray feedArray = response.getJSONArray("feed");
for (int i = 0; i < feedArray.length(); i++) {
feedObj = (JSONObject) feedArray.get(i);
Log.e("COUNTS", " " + feedObj.getString("count"));
textView.setText(feedObj.getString("count") + " count yeah");
textView.invalidate();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
}
});
// Adding request to volley request queue
AppController.getInstance().addToRequestQueue(jsonReq);
}
我尝试在“runOnUiThread”或“textView.post(new Runnable)”中设置文本...但这些不起作用..有什么建议吗?