问:专用void doAssign(){字符串nameStr = fname.getText()。toString(); 字符串phoneStr = phone.getText()。toString(); 字符串bikeStr = bike.getText()。toString();
字符串详细信息= nameStr +“,” + phoneStr +“,” + bikeStr;
RequestQueue队列= VolleySingleton.getsInstance()。getRequestQueue();
//字符串url =“ http://vvvv.com/vvv/campus/campus_assign.php?id='” + id +“'&details ='” +详细信息+“'”;
//我想像这样在URL中传递两个变量,但是它不起作用,我该怎么做?
CustomRequest jsonObjectRequest =新的CustomRequest(Request.Method.POST,URL,参数,新的Response.Listener <JSONObject>(){
@Override
公共无效onResponse(JSONObject response){
Log.d(“ Response:”,response.toString());
}
},新的Response.ErrorListener(){
@Override
public void onErrorResponse(VolleyError response){
Log.d(“ Response:”,response.toString());
}
}
);
queue.add(jsonObjectRequest);
}
答:希望下面的代码帮助你:Uri.Builder builder = new Uri.Builder();
builder.scheme("https")
.authority("abc.com")
.appendPath("xyz")
.appendQueryParameter("Variable1", var1)
.appendQueryParameter("Variable2", var2);
String url = builder.build().toString();