使用Recycler视图加载更多调用Api

时间:2017-10-27 09:38:11

标签: java android android-recyclerview

你好我有从api获取数据的Recycler视图,并且所有请求都给了我10个项目,知道我需要为这个回收器实现更多负载并且每个滚动得到另外10个项目,我尝试了很多次但是它没有工作,请帮助这是我的代码

适配器

   private int previousTotal = 0;
    private boolean loading = true;
    private int visibleThreshold = 0;
    int firstVisibleItem, visibleItemCount, totalItemCount;

 final LinearLayoutManager mLayoutManager = (LinearLayoutManager) mRecyclerView
                .getLayoutManager();

        mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {

            @Override
            public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                super.onScrolled(recyclerView, dx, dy);

                visibleItemCount = mRecyclerView.getChildCount();
                totalItemCount = mLayoutManager.getItemCount();
                firstVisibleItem = mLayoutManager.findFirstVisibleItemPosition();

                if (loading) {
                    if (totalItemCount > previousTotal) {
                        loading = false;
                        previousTotal = totalItemCount;
                    }
                }
                if (!loading && (totalItemCount - visibleItemCount)
                        <= (firstVisibleItem + visibleThreshold)) {
                    fragment.getHtmlNewsData("1");
                    loading = true;
                }
            }
        });

此处为活动

     public void getHtmlNewsData(final String pageNumber) {
        BusinessManager.getNewsDataMethod(pageNumber, new ApiCallResponse() {
            @Override
            public void onSuccess(String StringResponse) {
                String Response = (String) StringResponse;
                try {
                    html = Response.toString();
                    String[] MainSperatedList = html.toString().split("<div class=\"views-field views-field-field-date\">");

                    final List<String> stringsDate = new ArrayList<String>();
                    for (int counter = 1; counter < MainSperatedList.length; counter++) {
                        String Text = MainSperatedList[counter].toString();
                        String ItemSelected = Jsoup.parse(Text).select("span.date-display-single").text();
                        stringsDate.add(ItemSelected);
                        Log.d("AAAAAAA", ItemSelected);
                    }

 mLayoutManager = new LinearLayoutManager(context);
                    recyclerViewNews.setLayoutManager(mLayoutManager);
                    newsReycelerViewAdapter = new NewsReycelerViewAdapter(recyclerViewNews, context, stringsDate, stringsTitle, stringsDetails, stringsImages, new JPANewsFragment());
                    recyclerViewNews.setAdapter(newsReycelerViewAdapter);
                    if (!pageNumber.equals("0"))
                    newsReycelerViewAdapter.notifyDataSetChanged();
}
}

此代码对我不起作用,如果有人有想法请告诉我

4 个答案:

答案 0 :(得分:1)

我已经通过使用这两个工具来实现这一点并调用了recyclelerview方法addOnScrollListener。

首先在java包中创建这两个util:

<强> EndlessRecyclerOnScrollListener.java

package your.pakage.name;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();

private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;

private int current_page = 1;

private LinearLayoutManager mLinearLayoutManager;

public EndlessRecyclerOnScrollListener(LinearLayoutManager linearLayoutManager) {
    this.mLinearLayoutManager = linearLayoutManager;
}

@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    visibleItemCount = recyclerView.getChildCount();
    totalItemCount = mLinearLayoutManager.getItemCount();
    firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition();

    if (loading) {
        if (totalItemCount > previousTotal) {
            loading = false;
            previousTotal = totalItemCount;
        }
    }
    if (!loading && (totalItemCount - visibleItemCount)
            <= (firstVisibleItem + visibleThreshold)) {
        // End has been reached

        // Do something
        current_page++;

        onLoadMore(current_page);

        loading = true;
    }
}

   public abstract void onLoadMore(int current_page);
 }

<强> HidingScrollListener.java

package you.package.name;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;


public abstract class HidingScrollListener extends RecyclerView.OnScrollListener {

private static final int HIDE_THRESHOLD = 20;

private int mScrolledDistance = 0;
private boolean mControlsVisible = true;


@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
    super.onScrolled(recyclerView, dx, dy);

    int firstVisibleItem = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition();

    if (firstVisibleItem == 0) {
        if(!mControlsVisible) {
            onShow();
            mControlsVisible = true;
        }
    } else {
        if (mScrolledDistance > HIDE_THRESHOLD && mControlsVisible) {
            onHide();
            mControlsVisible = false;
            mScrolledDistance = 0;
        } else if (mScrolledDistance < -HIDE_THRESHOLD && !mControlsVisible) {
            onShow();
            mControlsVisible = true;
            mScrolledDistance = 0;
        }
    }
    if((mControlsVisible && dy>0) || (!mControlsVisible && dy<0)) {
        mScrolledDistance += dy;
    }
}

public abstract void onHide();
public abstract void onShow();
}

现在添加这两个之后创建你的activity.java就像这样:

<强> MyActivity.java

package your.package.name;


/**
 * Created by Admin on 9/26/2017.
 */

public class ProductFragment extends Fragment{
private ProductAdapter productAdapter;
private ProductLinearAdapter productLinearAdapter;
public static ArrayList<ProductModel> listProduct;
private RecyclerView mRecyclerviewProducts;
private boolean isGridView = false;
private AppBarLayout appBarLayout;
   // ProgressBar progressBar;
private ImageView iv_view;
private LinearLayout ll_sort,ll_filter;
private String checked=null;
private Button view_all;
RelativeLayout relativeLayout;
String category_id="";
HorizontalDotsProgressBar horizontalDotsProgressBar;
private String rupeeSymbol = "\u20B9";
//CardView cardView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_products,container,false);
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    horizontalDotsProgressBar = (HorizontalDotsProgressBar) view.findViewById(R.id.horizontalProgress);

    mRecyclerviewProducts = (RecyclerView) view.findViewById(R.id.rec_product_view);
    relativeLayout = (RelativeLayout) view.findViewById(R.id.rel_products);
    listProduct = new ArrayList<>();
    productAdapter = new ProductAdapter(getActivity(), listProduct);
    GridLayoutManager gridLayoutManager = new GridLayoutManager(getActivity(),2);
    mRecyclerviewProducts.setLayoutManager(gridLayoutManager);
    DividerItemDecoration dividerAppliancesVer = new DividerItemDecoration(
            mRecyclerviewProducts.getContext(),
            DividerItemDecoration.VERTICAL
    );
    DividerItemDecoration dividerAppliancesHor = new DividerItemDecoration(
            mRecyclerviewProducts.getContext(),
            DividerItemDecoration.HORIZONTAL
    );
    dividerAppliancesVer.setDrawable(ContextCompat.getDrawable(getContext(), R.drawable.shape_itemdecoration_vertical));
    dividerAppliancesHor.setDrawable(ContextCompat.getDrawable(getContext(), R.drawable.shape_itemdecoration_horizontal));
    mRecyclerviewProducts.addItemDecoration(dividerAppliancesVer);
    mRecyclerviewProducts.addItemDecoration(dividerAppliancesHor);
    mRecyclerviewProducts.setAdapter(productAdapter);
    mRecyclerviewProducts.addOnScrollListener(new EndlessRecyclerOnScrollListener(gridLayoutManager) {
        @Override
        public void onLoadMore(int current_page) {
            uiUpdate(category_id,current_page-1,"");
        }
    });
    Bundle bundle = getArguments();
    if (bundle != null) {
        category_id = bundle.getString("category_id");
        if (!category_id.equalsIgnoreCase(null)) {
            Toast.makeText(getActivity(), category_id, Toast.LENGTH_SHORT).show();

            uiUpdate(category_id,0,"");
        }
    }


    mRecyclerviewProducts.addOnScrollListener(new HidingScrollListener() {
        @Override
        public void onHide() {
            hideViews();
        }

        @Override
        public void onShow() {
            showViews();
        }
    });

}
private void uiUpdate(final String category_id, final int pagenumber, final String price){

    final Snackbar snackbar = Snackbar.make(relativeLayout,"Products Loading...",Snackbar.LENGTH_SHORT);
    snackbar.show();
    //final ProgressDialog progressDialog=new ProgressDialog(getActivity());
    //progressDialog.show();
    StringRequest stringRequest = new StringRequest(Request.Method.GET, "http://kibakibi.com/categoryproductapi?access_token=awerttshhjsekjkuy&categoryid=" + category_id+"&page="+pagenumber+"&price="+price,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    try {

                        Log.d("HomeFragment", "onResponse: " + response);
                        // Toast.makeText(getActivity(),response,Toast.LENGTH_SHORT).show();
                        JSONObject jsonRootObject = new JSONObject(response);
                        JSONArray jsonArray = jsonRootObject.getJSONArray("products");
                        String message = jsonRootObject.getString("message");
                        //progressDialog.dismiss();
                        snackbar.dismiss();
                        horizontalDotsProgressBar.clearAnimation();
                        horizontalDotsProgressBar.setVisibility(View.GONE);
                        //Toast.makeText(getActivity(),message,Toast.LENGTH_SHORT).show();
                        if(message.trim().equalsIgnoreCase("Success")){
                            //progressBar.setVisibility(View.GONE);

                            for (int i = 0; i < jsonArray.length(); i++) {
                                JSONObject jsonObject = jsonArray.getJSONObject(i);
                                String productId = jsonObject.optString("api_product_id");
                                String categoryId = jsonObject.optString("categoryId");
                                String product_Title = jsonObject.optString("productTitle");
                                String previousPrice =  jsonObject.optString("mrp");
                                String actualPrice = jsonObject.optString("expected_payout");
                                String sellerId = jsonObject.optString("seller_id");
                                String description = jsonObject.optString("description");
                                String imageurl = jsonObject.optString("product_images");
                                listProduct.add(new ProductModel(productId,product_Title,imageurl,categoryId,previousPrice,description,actualPrice,sellerId));
                            }
                        }

                    } catch (JSONException e) {
                        e.printStackTrace();
                    }
                    productAdapter.notifyItemRangeInserted(pagenumber*1,1);
                    //productAdapter.notifyDataSetChanged();

                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {
                    Log.e("Volley", "Error");

                }
            }
    );
    RetryPolicy retryPolicy = new DefaultRetryPolicy(30000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    stringRequest.setRetryPolicy(retryPolicy);
    VolleySingleton.getInstance(getActivity()).addToRequestQueue(stringRequest);
}

private void hideViews() {
   // cardView.animate().translationY(-cardView.getHeight()).setInterpolator(new AccelerateInterpolator(2));
}
private void showViews() {
   // cardView.animate().translationY(0).setInterpolator(new DecelerateInterpolator(2));
}
}

并非适配器的变化,但我要添加它:

<强> MyAdapter.java

package your.package.name;



public class ProductAdapter extends 
RecyclerView.Adapter<ProductAdapter.MyViewHolder> {
    private ArrayList<ProductModel> list;
    private ArrayList<ProductModel> filterList;
    Context mContext;
    private static final int MAX_WIDTH = 400;
private static final int MAX_HEIGHT = 400;
int size = (int) Math.ceil(Math.sqrt(MAX_WIDTH * MAX_HEIGHT));
private String rupeeSymbol = "\u20B9";
public ProductAdapter(Context mContext, ArrayList<ProductModel> list) {
    this.list = list;
    this.filterList=list;
    this.mContext = mContext;
}

@Override
public ProductAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_products, parent, false);
    return new ProductAdapter.MyViewHolder(itemView);
}

@Override
public void onBindViewHolder(final ProductAdapter.MyViewHolder holder, int position) {
    Typeface montserratregular = Typeface.createFromAsset(mContext.getAssets(), "font/montserratregular.ttf");
    final ProductModel productModel = filterList.get(position);
    //setting width & height
  /*  DisplayMetrics displayMetrics = new DisplayMetrics();
    ((Activity) mContext).getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int height = displayMetrics.heightPixels / 4;
    int width = (int) (displayMetrics.widthPixels * 0.9);
    holder.itemView.setLayoutParams(new LinearLayout.LayoutParams(width, height));*/
    holder.product_name.setText(productModel.getProduct_title());
    Picasso.with(mContext)
            .load(productModel.getProduct_imageFront())
            .transform(new BitmapTransForms(MAX_WIDTH, MAX_HEIGHT))
            .into(holder.product_image);
    holder.tv_actualPrice.setText(rupeeSymbol+productModel.getExpected_payout());
    holder.tv_previousPrice.setText(rupeeSymbol+productModel.getMrp());
    holder.tv_previousPrice.setPaintFlags(holder.tv_previousPrice.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
   // holder.tv_percentOff.setText(productModel.getMargin());

    // Toast.makeText(mContext,productModel.getProduct_title(),Toast.LENGTH_LONG).show();
    holder.tv_actualPrice.setTypeface(montserratregular);
    holder.tv_previousPrice.setTypeface(montserratregular);
    holder.tv_percentOff.setTypeface(montserratregular);
    holder.tv_ratingNumber.setTypeface(montserratregular);
    holder.product_name.setTypeface(montserratregular);
    holder.tv_rating.setTypeface(montserratregular);
}

@Override
public int getItemCount() {

    return filterList.size();

}

class MyViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
    TextView product_name,tv_actualPrice,tv_previousPrice,tv_percentOff,tv_ratingNumber,tv_rating;
    ImageView product_image;
    MyViewHolder(View itemView) {
        super(itemView);
        product_name = (TextView) itemView.findViewById(R.id.tv_productname);
        product_image = (ImageView) itemView.findViewById(R.id.iv_products);
        tv_actualPrice = (TextView) itemView.findViewById(R.id.tv_actualPrice);
        tv_previousPrice = (TextView) itemView.findViewById(R.id.tv_previousPrice);
        tv_ratingNumber = (TextView) itemView.findViewById(R.id.tv_ratingNumber);
        tv_rating = (TextView) itemView.findViewById(R.id.tv_rating);
        tv_percentOff = (TextView) itemView.findViewById(R.id.tv_percentOff);
        itemView.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        final ProductModel productModel = filterList.get(getAdapterPosition());
        Intent i = new Intent(mContext, SingleProductView.class);
        i.putExtra("image",productModel.getProduct_imageFront());
        i.putExtra("name",productModel.getProduct_title());
        i.putExtra("actualprice",productModel.getExpected_payout());
        i.putExtra("previousPrice",productModel.getMrp());
        i.putExtra("productId",productModel.getApi_product_id());
        Toast.makeText(mContext,productModel.getApi_product_id(),Toast.LENGTH_LONG).show();
        mContext.startActivity(i);
    }
}
}

它肯定会在Youractivity.java页面编号上尝试它,如果您的第一页获得十,那么在滚动后它将增加并获得第二页值,现在您的回收器上有20个项目。如果有任何问题,请告诉我评论,我会让他们离开。

答案 1 :(得分:0)

RecyclerView.java

使用 addOnScrollListener(OnScrollListener侦听器)
/**
 * Add a listener that will be notified of any changes in scroll state or position.
 *
 * <p>Components that add a listener should take care to remove it when finished.
 * Other components that take ownership of a view may call {@link #clearOnScrollListeners()}
 * to remove all attached listeners.</p>
 *
 * @param listener listener to set or null to clear
 */
public void addOnScrollListener(OnScrollListener listener)

实现:

recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
        @Override
        public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
            if (dy > 0 && loadingData) {
                visibleItemCount = layoutManager.getChildCount();
                totalItemCount = layoutManager.getItemCount();
                pastVisiblesItems = layoutManager.findFirstVisibleItemPosition();
                if ((visibleItemCount + pastVisiblesItems) >= totalItemCount) {
                    //loading flag set to false once data received for the scroll
                    loadingData = false;
                    //Network call using pagination information when scrolled
                    get(pagination, networkRequest);
                }
            }
        }
    });
    clearData();
    //Initial network call to get data from network
    get(pagination, networkRequest);

答案 2 :(得分:0)

    **Adapter**

    public class ChooseTeamAdapter extends RecyclerView.Adapter<ChooseTeamAdapter.MyViewHolder> {


        public interface OnDeleteItemClickListener {

            public void onDeleteClicked();

        }

        OnDeleteItemClickListener onDeleteItemClickListener;

        private String TAG="ChooseTeamAdapter";
        Context context;
        private ArrayList<ChooseTeam.Featured> dataArrayList;
        ArrayList<String> arrayList = new ArrayList<String>();

        public static ArrayList<String> strCreditId=new ArrayList<>();

        public ChooseTeamAdapter(Context context, ArrayList<ChooseTeam.Featured> dataArrayList,OnDeleteItemClickListener monDeleteItemClickedListener) {
            this.context = context;
            this.dataArrayList = dataArrayList;
            this.onDeleteItemClickListener = monDeleteItemClickedListener;
        }

        @Override
        public ChooseTeamAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

            View itemView = LayoutInflater.from(parent.getContext())
                    .inflate(R.layout.list_item_team, parent, false);
            return new ChooseTeamAdapter.MyViewHolder(itemView);


        }

        @Override
        public void onBindViewHolder(final ChooseTeamAdapter.MyViewHolder holder, final int position) {

            holder.tvName.setText(dataArrayList.get(position).name);


            Picasso.with(context)
                    .load(dataArrayList.get(position).icon)
                    .placeholder(R.drawable.ndtv)
                    .into(holder.ivProfile);

            //click event for add
            holder.ivAdd.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    holder.ivAdd.setVisibility(View.GONE);
                    holder.ivChecked.setVisibility(View.VISIBLE);

                    //arrayList.add(dataArrayList.get(position).id);
                    strCreditId.add(dataArrayList.get(position).id);
                    Log.e(TAG,"ARRAYLIST SIZE==>"+strCreditId.size());

                    //onDeleteItemClickListener.onDeleteClicked();
                    Utils.WriteSharePrefrence(context, Constant.TEAM_NAME, strCreditId.toString().replace("[", "").replace("]", ""));

                }
            });

            //click event for ivChecked
            holder.ivChecked.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {

                    holder.ivChecked.setVisibility(View.GONE);
                    holder.ivAdd.setVisibility(View.VISIBLE);

                    strCreditId.remove(dataArrayList.get(position).id);
                    Log.e(TAG,"ARRAYLIST SIZE==>"+strCreditId.size());
                    Utils.WriteSharePrefrence(context, Constant.TEAM_NAME, strCreditId.toString().replace("[", "").replace("]", ""));
                }
            });


        }

        @Override
        public int getItemCount() {
            return dataArrayList.size();
        }

        public class MyViewHolder extends RecyclerView.ViewHolder {

            private TextView tvName;
            private ImageView ivProfile;
            private ImageView ivAdd;
            private ImageView ivChecked;


            public MyViewHolder(View itemView) {
                super(itemView);

                tvName=itemView.findViewById(R.id.tv_teamname);
                ivProfile=itemView.findViewById(R.id.iv_team);
                ivAdd=itemView.findViewById(R.id.iv_add);
                ivChecked=itemView.findViewById(R.id.iv_checked);
            }
        }
    }



**Recyclerview**


    private String TAG = "ChooseTeamActivity";
    private Toolbar toolbar;
    private ProgressDialog progress;
    private RecyclerView rvTeam;
    private ArrayList<ChooseTeam.Featured> teamArrayList;
    private ChooseTeamAdapter chooseTeamAdapter;
    private TextView tvDone;
    private String teamid;


        getChooseteam();

 private void Hideprogress() {
        // TODO Auto-generated method stub
        if (progress.isShowing()) {
            progress.dismiss();
        }
    }

    private void ShowProgress() {
        // TODO Auto-generated method stub
        progress = new ProgressDialog(ChooseTeamActivity.this);
        progress.setMessage("Please wait...");
        progress.setCancelable(false);
        progress.show();
    }

    //API call for Chooseteam
    private void getChooseteam() {
        AsyncHttpClient client = new AsyncHttpClient();
        RequestParams requestParams = new RequestParams();
        Log.e(TAG, "CHOOSE_TEAM_URL==>" + Urls.TEAM_LIST + requestParams);
        client.post(Urls.TEAM_LIST, requestParams, new JsonHttpResponseHandler() {

            @Override
            public void onStart() {
                super.onStart();
                ShowProgress();
            }

            @Override
            public void onFinish() {
                super.onFinish();
                Hideprogress();
            }

            @Override
            public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
                super.onSuccess(statusCode, headers, response);
                Log.e(TAG, "CHOOSE_TEAM_URL RESPONSE-" + response);

                if (response.equals("")) {
                    Toast.makeText(ChooseTeamActivity.this, "Something Wrong!", Toast.LENGTH_SHORT).show();
                } else {

                    if (!response.equals("")) {
                        ChooseTeam team = new Gson().fromJson(String.valueOf(response), ChooseTeam.class);
                        if (team.status.equals("true")) {
                            if (team.featuredArrayList.size() > 0) {
                                teamArrayList = team.featuredArrayList;
                                RecyclerView.LayoutManager mLayoutManager = new GridLayoutManager(ChooseTeamActivity.this, 1);
                                rvTeam.setLayoutManager(mLayoutManager);
                                chooseTeamAdapter = new ChooseTeamAdapter(ChooseTeamActivity.this, teamArrayList, ChooseTeamActivity.this);
                                rvTeam.setAdapter(chooseTeamAdapter);
                            } else {
                                Toast.makeText(ChooseTeamActivity.this, "Data Not Found!", Toast.LENGTH_SHORT).show();
                            }

                        } else {

                            Toast.makeText(ChooseTeamActivity.this, team.message, Toast.LENGTH_SHORT).show();
                        }
                    } else {
                        Toast.makeText(ChooseTeamActivity.this, "something went wrong!", Toast.LENGTH_SHORT).show();
                    }
                }
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, String responseString, Throwable throwable) {
                super.onFailure(statusCode, headers, responseString, throwable);
                Hideprogress();
                Toast.makeText(ChooseTeamActivity.this, "Something Wrong!", Toast.LENGTH_SHORT).show();
                Log.e(TAG, throwable.getMessage());
            }
        });

    }

答案 3 :(得分:0)

**Library**

    implementation 'com.intuit.sdp:sdp-android:1.0.4'
 implementation 'com.loopj.android:android-async-http:1.4.9'
    implementation 'com.google.code.gson:gson:2.2.4'
    implementation 'com.squareup.picasso:picasso:2.5.2'
    implementation 'com.android.support:cardview-v7:26+'
    implementation 'com.android.support:recyclerview-v7:26.1.0'
    implementation 'de.hdodenhof:circleimageview:2.2.0'


**Choose team activity**

    <android.support.v7.widget.RecyclerView
        android:id="@+id/rv_team"
        android:layout_below="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
    </android.support.v7.widget.RecyclerView>





**list_item_team**

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingLeft="@dimen/_5sdp"
    android:paddingRight="@dimen/_5sdp">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <ImageView
                android:id="@+id/iv_team"
                android:layout_width="@dimen/_50sdp"
                android:layout_height="@dimen/_30sdp"
                android:layout_weight="0.1"
                android:layout_marginTop="@dimen/_10sdp"
                android:src="@drawable/ndtv" />

            <TextView
                android:id="@+id/tv_teamname"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
               android:layout_gravity="center"
                android:layout_marginLeft="@dimen/_10sdp"
                android:layout_weight="1"
                android:text="Rockies"
                android:textColor="@color/black"
                android:textStyle="bold" />



            <ImageView
                android:id="@+id/iv_add"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_20sdp"
                android:layout_gravity="center"
                android:layout_weight="3"
                android:src="@drawable/ic_add" />


            <ImageView
                android:id="@+id/iv_checked"
                android:layout_width="match_parent"
                android:layout_height="@dimen/_30sdp"
                android:layout_gravity="center"
                android:layout_weight="3"
                android:src="@drawable/ic_checked"
                android:visibility="gone"

                />



        </LinearLayout>

        <View
            android:layout_width="match_parent"
            android:layout_height="0.5dp"
            android:background="#E4E4E4"
            android:layout_marginTop="@dimen/_4sdp"
            ></View>
    </LinearLayout>
</RelativeLayout>