您好,我在让Alpha Vantage api正常工作时遇到问题。 我想要得到的就是最后几天的收盘价。 我不确定自己在做什么错。 目前,我唯一的目标是在最后一天关闭时将其简单地更改为TextView“ tvStockClose”。 现在的错误是运行时错误。 任何方向的任何帮助都将受到赞赏和欢迎。
API: 链接
public void loadData() {
progressDialog.setMessage("Retrieving Data, Please Be Patient");
progressDialog.show();
Toast.makeText(getApplicationContext(), "1 :D", Toast.LENGTH_SHORT).show();
StringRequest stringRequest = new StringRequest(Request.Method.GET,
URL2,
new Response.Listener() {
@Override
public void onResponse(String response) {
Toast.makeText(getApplicationContext(), "2 :D", Toast.LENGTH_SHORT).show();
try {
Toast.makeText(getApplicationContext(), "3:D", Toast.LENGTH_SHORT).show();
mStockList.clear();
JSONObject jsonObject = new JSONObject(response);
String addThis = jsonObject.getJSONObject("20171102").getString("close");
tvStockClose.setText(addThis);
TestStockList testStockList = new TestStockList(addThis);
mStockList.add(testStockList);
Toast.makeText(StockTest.this, addThis, Toast.LENGTH_SHORT).show();
mAdapter = new TestMyAdapterStockList(mStockList, getApplicationContext());
recyclerView.setAdapter(mAdapter);
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "4 :D", Toast.LENGTH_SHORT).show();
} catch (JSONException e) {
//Toast.makeText(getContext(), "5 :D", Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
progressDialog.dismiss();
Toast.makeText(getApplicationContext(), "6 :D", Toast.LENGTH_SHORT).show();
Toast.makeText(getApplicationContext(), "Something Went Wrong, try Again", Toast.LENGTH_SHORT).show();
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getApplicationContext());
requestQueue.add(stringRequest);
Toast.makeText(getApplicationContext(), "7 :D", Toast.LENGTH_SHORT).show();
}