首先咱先写写布局文件啊
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:background="#ff3660" android:gravity="center_vertical" android:orientation="horizontal"> <ImageView android:id="@+id/ivZxing" android:layout_width="30dp" android:layout_height="30dp" android:layout_marginLeft="15dp" android:background="@drawable/a_s"/> <LinearLayout android:layout_width="match_parent" android:layout_height="30dp" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" android:layout_weight="1" android:background="@drawable/shape_search"></LinearLayout> <ImageView android:layout_width="30dp" android:layout_height="30dp" android:layout_alignParentRight="true" android:layout_marginRight="15dp" android:background="@drawable/my_msg_bai"/> </LinearLayout> <com.jcodecraeer.xrecyclerview.XRecyclerView android:id="@+id/xrv" android:layout_width="match_parent" android:layout_height="match_parent"></com.jcodecraeer.xrecyclerview.XRecyclerView> </LinearLayout>
这个是列表适配器的布局rvlist_item.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/ll" android:layout_width="match_parent" android:layout_height="100dp" android:orientation="horizontal"> <com.facebook.drawee.view.SimpleDraweeView android:id="@+id/iv" android:layout_width="70dp" android:layout_height="70dp"/> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:orientation="vertical"> <TextView android:id="@+id/tvTitle" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/tvPrice" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:textColor="#ff0000"/> </LinearLayout> </LinearLayout>
下面写contract
ListContract
public interface ListContract { interface View extends BaseContract.BaseView { void onSuccess(List<ProductsBean.DataBean> list); } interface Presenter extends BaseContract.BasePresenter<View> { void getProducts(String pscid); } }
写presenter
ListPresenter
public class ListPresenter extends BasePresenter<ListContract.View> implements ListContract.Presenter { private ListApi listApi; @Inject public ListPresenter(ListAp