Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在模型中添加横幅广告_Java_Json_Model_Banner - Fatal编程技术网

Java 在模型中添加横幅广告

Java 在模型中添加横幅广告,java,json,model,banner,Java,Json,Model,Banner,我需要加载横幅广告后显示10条评论模型。 我如何才能做到这一点,当用户在每10条评论后加载评论时,就会显示一条广告。我在活动中使用此代码 public void sendCommentRequestFirstTime(){ lastId = "0"; itShouldLoadMore = false; // lock this guy,(itShouldLoadMore) to make sure, user will not load more whe

我需要加载横幅广告后显示10条评论模型。 我如何才能做到这一点,当用户在每10条评论后加载评论时,就会显示一条广告。我在活动中使用此代码

 public void sendCommentRequestFirstTime(){
     lastId = "0";
     itShouldLoadMore = false; // lock this guy,(itShouldLoadMore) to make sure, user will not load more when volley is processing another request only load more when  volley is free
     progressWheelInterpolated.setVisibility(View.VISIBLE);

     JsonArrayRequest jsonArrayRequest = new JsonArrayRequest(Request.Method.GET, Config.GET_COMMENT_URL+"?limit="+Config.LOAD_LIMIT+"&content_id="+contentId+"&last_id="+lastId+"&api_key="+Config.API_KEY, null, new Response.Listener<JSONArray>() {
         @Override
         public void onResponse(JSONArray response) {
             itShouldLoadMore = true;
             if (response.length() == 0)
             {
                 //No result found!
                 Toast.makeText(ShowComment.this, R.string.txt_no_result, Toast.LENGTH_SHORT).show();
             }
             for(int i = 0; i < response.length(); i++){
                 CommentModel commentModel = new CommentModel();

                 try {
                     JSONObject jsonObject = response.getJSONObject(i);

                     lastId = jsonObject.getString("comment_id");

                     commentModel.setUser_username(jsonObject.getString("user_username"));
                     commentModel.setComment_user_id(jsonObject.getString("comment_user_id"));
                     commentModel.setComment_text(jsonObject.getString("comment_text"));
                     commentModel.setComment_time(jsonObject.getString("comment_time"));
                     commentModel.setComment_rate(jsonObject.getString("comment_rate"));
                     commentModel.setUser_image(jsonObject.getString("user_image"));

                 } catch (JSONException e) {
                     e.printStackTrace();
                 }
                 commentModelsList.add(commentModel);
                 mAdapter.notifyDataSetChanged();
                 progressWheelInterpolated.setVisibility(View.GONE);
             }
         }
     }, new Response.ErrorListener() {
         @Override
         public void onErrorResponse(VolleyError error) {
             progressWheelInterpolated.setVisibility(View.GONE);
             itShouldLoadMore = true;
             Log.i("BlueDev Volley Error: ", error+"");
             Snackbar snackbar = Snackbar.make(showCommentConstraintlayout, R.string.txt_no_result, Snackbar.LENGTH_LONG);
             snackbar.show();
         }
     });

     jsonArrayRequest.setRetryPolicy(new DefaultRetryPolicy(25000,2,DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
     rqComment.add(jsonArrayRequest);
 }```
public void sendCommentRequestFirstTime(){
lastId=“0”;
itShouldLoadMore=false;//锁定这个家伙,(itShouldLoadMore)以确保当截击处理另一个请求时用户不会加载更多,只有在截击空闲时才会加载更多
progressWheelInterpolated.setVisibility(View.VISIBLE);
JsonArrayRequest JsonArrayRequest=新JsonArrayRequest(Request.Method.GET,Config.GET_COMMENT_URL+“?limit=“+Config.LOAD_limit+”&content_id=“+contentId+”&last_id=“+lastId+”&api_key=“+Config.api_key,null,new Response.Listener()){
@凌驾
公共void onResponse(JSONArray响应){
itshoulloadmore=true;
if(response.length()==0)
{
//没有结果!
Toast.makeText(showcoment.this,R.string.txt_no_result,Toast.LENGTH_SHORT).show();
}
对于(int i=0;i