我使用排球库从json文件接收数据我有这个问题我不知道这个错误的原因
尝试调用虚拟方法' android.content.Context.getResources()'在空对象引用上
private void fetchRemoteData(final DataStatus callback){
StringRequest stringRequest = new StringRequest(Request.Method.GET,
URL_DATA,
new Response.Listener<String>() {
@Override
public void onResponse(String s) {
List<Post> listItems = new ArrayList<>();
try {
JSONObject jsonObject = new JSONObject(s);
JSONArray array = jsonObject.getJSONArray("bgs");
for (int i = 0; i < array.length(); i++){
JSONObject o = array.getJSONObject(i);
Post item = new Post(
o.getString("img")
);
listItems.add(item);
}
callback.onSuccess(listItems);
} catch (JSONException e) {
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
callback.onError(error);
}
});
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());
requestQueue.add(stringRequest);
}
错误存在于此处:
@Override
public void onErrorResponse(VolleyError error) {
callback.onError(error);
}
答案 0 :(得分:1)
更新此行:
data=load ('Q2Even');
histogram(data.y)
phat = mle(data.y,'distribution','normal')
与
phat =
26.9900 7.3849
或
RequestQueue requestQueue = Volley.newRequestQueue(getActivity());