【发布时间】:2017-02-20 15:42:32
【问题描述】:
这就是问题所在: 当我尝试通过 php 页面查询数据库时,查询结果没有“到达”智能手机。
setPartenza(tBoxPartenza.getText().toString());
setArrivo(tBoxArrivo.getText().toString());
final String KEY_FERM1 = "ferm_1";
final String KEY_FERM2 = "ferm_2";
String url = "<url>";
String ferm_1, ferm_2, jsonresp;
String result = null;
StringRequest stringRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Toast.makeText(MainActivity.this, "Response: " + response, Toast.LENGTH_SHORT).show();
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(MainActivity.this, "That didn't work!", Toast.LENGTH_SHORT).show();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<>();
params.put(KEY_FERM1, getPartenza());
params.put(KEY_FERM2, getArrivo());
return params;
}
};
// Add the request to the RequestQueue.
RequestQueue queue = Volley.newRequestQueue(this);
queue.add(stringRequest);
if (result != null) {
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
recyclerView = (RecyclerView) findViewById(R.id.mainRecyclerView);
recyclerView.setLayoutManager(layoutManager);
MainRecyclerAdapter adapter = null;
try {
adapter = new MainRecyclerAdapter(getApplicationContext(), result);
} catch (JSONException e) {
e.printStackTrace();
}
recyclerView.setAdapter(new AlphaInAnimationAdapter(adapter));
} else {
Toast.makeText(this, "result == null", Toast.LENGTH_SHORT).show();
}
当系统执行此操作时,在回收器中不会出现任何内容,因为结果变量不等于任何内容,好吧,我不知道 volley 是否在查询到达之前获得锁,而且我确定结果php页面,但我不知道我错在哪里,有什么想法吗???
【问题讨论】:
标签: php android mysql android-recyclerview android-volley