我在活动类中定义了一个函数,如下所示:
private void passParam(String pname){
StringRequest compareRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
//handle response code
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError arg0) {}
}) {
@Override
protected Map<String, String> getParams() {
//set post params
Map<String, String> params = new HashMap<String, String>();
params.put("foo", "foo");
params.put("name", pname);//Grammar error, want to use parameter pname
return params;
}
};
requestQ.add(compareRequest);
}
我想将post参数“name”值设置为函数pname
的参数passParam
。如何方便地执行此操作?谢谢!