how can get integer json value in secondary layout (end of recycler view)
<p>this is my json :</p>

<pre><code>{
  "status": "ok",
  "count": 10,
  "count_total": 65,
  "pages": 7,
  "posts": [
    {
      "id": 3115,
      "type": "post",
.
.
.
}]}
</code></pre>

<p>want get pages value end of my recycler view :
<a href="https://i.stack.imgur.com/BHoI7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BHoI7.jpg" alt="enter image description here"></a></p>

<p>this is my AsyncTask function to get json :</p>

<pre><code> if (jsonStr != null) {
                    try {

                        JSONObject jsonObj = new JSONObject(jsonStr);


                        int id=jsonObj.getInt("pages");


                        JSONArray posts = jsonObj.getJSONArray("posts");
                        for (int i = 0; i &lt; posts.length(); i++) {
                            JSONObject c = posts.getJSONObject(i);

                            jsonContent jsonContent=new jsonContent();

                            jsonContent.title=c.getString("title");

                            //img
                           JSONObject post_img=c.getJSONObject("thumbnail_images");
                            for (int j=0;j&lt;post_img.length();j++)
                            {
                                JSONObject v=post_img.getJSONObject("mom-portfolio-two");
                                jsonContent.imgurl=v.getString("url");
                            }
                            jsonContent.pages=id;
                            listcontent.add(jsonContent);

                        }
</code></pre>

<p>and this is my adapter :</p>

<pre><code>  public class DataAdapter extends RecyclerView.Adapter&lt;DataAdapter.ViewHolder&gt; {
        private Context context;
        List&lt;jsonContent&gt; jcontent;



        public DataAdapter(Context context,List&lt;jsonContent&gt; jcontent) {

            this.context=context;
            this.jcontent=jcontent;

        }



        @Override
        public DataAdapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {

           View view ;
            if(i == R.layout.card_row) {
                view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.card_row, viewGroup, false);
            }else {
                view = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.button_card, viewGroup, false);
            }
            return new ViewHolder(view);
        }

        @Override
        public void onBindViewHolder(final DataAdapter.ViewHolder viewHolder,int i) {


            if(i == jcontent.size()) {
                viewHolder.buttonnext.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Toast.makeText(context, "next", Toast.LENGTH_SHORT).show();
                    }
                });
                viewHolder.buttonprev.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Toast.makeText(context, "pre", Toast.LENGTH_SHORT).show();
                    }
                });

                viewHolder.cardView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                    }
                });

                viewHolder.pages.setText(Integer.toString(jcontent.get(i).pages));

            }
            else {

                viewHolder.title.setText(jcontent.get(i).title);

                Picasso.with(context).load(jcontent.get(i).imgurl).resize(300, 400).into(viewHolder.imageView);

            }
        }

        @Override
        public int getItemCount() {
                return jcontent.size()+1;
        }

        @Override
        public int getItemViewType(int position) {
            return (position == jcontent.size()) ? R.layout.button_card : R.layout.card_row;
        }


        public class ViewHolder extends RecyclerView.ViewHolder{

            private TextView title,pages;

            private ImageView imageView;

            private Button buttonnext,buttonprev;

            private CardView cardView;


            public ViewHolder(final View view) {
                super(view);


               title = (TextView)view.findViewById(R.id.post_title);
                imageView=(ImageView)view.findViewById(R.id.img);
                buttonnext =(Button)view.findViewById(R.id.next);
                buttonprev=(Button)view.findViewById(R.id.prev);
                cardView=(CardView)view.findViewById(R.id.cvv);

                pages=(TextView)view.findViewById(R.id.number_pages);
    }
    }
    }
</code></pre>

<p>but when launch app and scroll down to end of recycler view when become to to end of recycler app crash and got this error :</p>

<pre><code> FATAL EXCEPTION: main
java.lang.IndexOutOfBoundsException: Invalid index 10, size is 10
</code></pre>

<p>from this line : </p>

<pre><code> viewHolder.pages.setText(Integer.toString(jcontent.get(i).pages));
</code></pre>

<p>and pages is my text view for show pages int value in secondary layount end of recycler view </p>