【发布时间】:2016-11-30 09:06:25
【问题描述】:
我的编辑器收到警告。
作为原始类型的成员对“GsonRequest(int, String, Class, Map, Listener, ErrorListener)”的未经检查的调用 'com.inc.woppi.demoapp.GsonRequest'
GsonRequest 类复制自 Android Dev:https://developer.android.com/training/volley/request-custom.html
当我的电话在下面时:
// args: url, gson class, response listener, error listener
final GsonRequest gsonRequest = new GsonRequest(
apiUrl,
SeatRequestModel.class,
null,
new Response.Listener<SeatRequestModel>() {
@Override
public void onResponse(SeatRequestModel res) {
try {
boolean errorFound = res.isError();
if(errorFound) {
//handle error
} else {
String seatId = res.getData().getSeatId();
}
} catch (Exception e) {
Toast.makeText(activityContext, activityContext.getResources().getString(R.string.err_system_response_format_error), Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//handle error
}
}){
@Override
protected Map<String,String> getParams(){
Map<String,String> params = new HashMap<String, String>();
params.put("from", "australia");
params.put("to", "canada");
return params;
}
@Override
public Map<String, String> getHeaders() throws AuthFailureError {
Map<String,String> params = new HashMap<String, String>();
return params;
}
};
// add the request to the RequestQueue.
VolleySingleton.getInstance(this.getApplicationContext()).addToRequestQueue(gsonRequest);
【问题讨论】:
-
final GsonRequest<SeatRequestModel> gsonRequest = new GsonRequest<>( -
不错!我希望您提交答案,以便我将其评为最佳答案。太感谢了! :) 我不得不编辑新的 GsonRequest
标签: android android-volley android-debug