详情页面和MVP二级购物车

用的是:retrofit,rxjava,fresco

MVP就不写在上面了,直接去github上看: github链接
记得要在Bean类里添加三个参数

详情页面:



购物车页面:



首先是先导入依赖:

compile 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
compile 'com.facebook.fresco:fresco:0.8.1+'
compile 'com.squareup.retrofit2:retrofit:2.3.0'
compile 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
compile "io.reactivex.rxjava2:rxjava:2.1.1"
compile 'io.reactivex.rxjava2:rxandroid:2.0.1'
compile 'com.squareup.retrofit2:converter-gson:2.3.0'
compile 'com.github.liuguangqiang.SuperRecyclerView:super-recyclerview:0.1.2'

values下colors的:
 <color name="colorPrimary">#3F51B5</color>
    <color name="colorPrimaryDark">#303F9F</color>
    <color name="colorAccent">#FF4081</color>


    <color name="cwhite">#FFFFFF</color>

    <color name="title_bg">#FDE23D</color>

    <color name="tab_bg">#FFFFFF</color>

    <color name="tab_normal_textcolor">#373737</color>
    <color name="tab_selected_textcolor">#FDE23D</color>

    <color name="coffer">#442509</color>

    <color name="pressed_icon_color">#e53e42</color>

    <color name="background_color">#f6f6f6</color>

    <color name="main_red_text">#e53e42</color>
    <dimen name="padding_20dp">20dp</dimen>

    <color name="splitline_color">#dddddd</color>

    <color name="cblack">#000000</color>

values下创建dimens:
 <dimen name="margin_10dp">10dp</dimen>


    <dimen name="padding_5dp">5dp</dimen>
    <dimen name="padding_10dp">10dp</dimen>


    <dimen name="common_font_size_16">16sp</dimen>
    <dimen name="common_font_size_14">14sp</dimen>


    <dimen name="height_200dp">200dp</dimen>

    <dimen name="margin_30dp">30dp</dimen>
    <dimen name="margin_15dp">15dp</dimen>
    <dimen name="margin_1dp">1dp</dimen>
    <dimen name="margin_5dp">5dp</dimen>
    <dimen name="common_font_size_12">12sp</dimen>

    <dimen name="padding_2dp">2dp</dimen>
    <dimen name="margin_20dp">20dp</dimen>


mainactivity布局页面:
<RelativeLayout 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="wrap_content"
        android:orientation="vertical">

        <com.facebook.drawee.view.SimpleDraweeView
            android:id="@+id/simple"
            android:layout_width="match_parent"
            android:layout_height="350dp" />

        <TextView
            android:id="@+id/title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <TextView
            android:id="@+id/sub"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView
                android:id="@+id/youhui"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ff0000" />

            <TextView
                android:id="@+id/price"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentRight="true" />
        </RelativeLayout>
    </LinearLayout>

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

        <Button
            android:id="@+id/gowuche"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="购物车" />

        <Button
            android:id="@+id/addgowuche"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="加入购物车" />
    </LinearLayout>
</RelativeLayout>
gowucheactivity页面布局:
<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">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/third_recyclerview"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_weight="1" />


    <LinearLayout
        android:id="@+id/third_pay_linear"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="0"
        android:background="#FFFFFF"
        android:gravity="center_vertical"
        android:orientation="horizontal">

        <CheckBox
            android:id="@+id/third_allselect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/margin_10dp"
            android:drawablePadding="@dimen/padding_5dp"
            android:text="全选" />

        <LinearLayout
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:orientation="vertical">

            <TextView
                android:id="@+id/third_totalprice"
                android:layout_width="200dp"
                android:layout_height="wrap_content"
                android:paddingLeft="@dimen/padding_10dp"
                android:paddingTop="@dimen/padding_10dp"
                android:text="总价:"
                android:textColor="@color/cblack"
                android:textSize="@dimen/common_font_size_16" />

            <TextView
                android:id="@+id/third_totalnum"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="@dimen/padding_10dp"
                android:paddingLeft="@dimen/padding_10dp"
                android:text="共0件商品"
                android:textColor="@color/cblack"
                android:textSize="@dimen/common_font_size_14" />

        </LinearLayout>

        <TextView
            android:id="@+id/third_submit"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="@dimen/margin_10dp"
            android:background="@drawable/login_btn"
            android:paddingBottom="@dimen/padding_10dp"
            android:paddingLeft="@dimen/margin_30dp"
            android:paddingRight="@dimen/margin_30dp"
            android:paddingTop="@dimen/padding_10dp"
            android:text="去结算"
            android:textColor="#000000" />

    </LinearLayout>
</LinearLayout>

myadapter适配器布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/ll_shopcart_header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <View
            android:id="@+id/view"
            android:layout_width="match_parent"
            android:layout_height="@dimen/margin_10dp"
            android:background="@color/background_color" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="center_vertical">
            <!-- 商店checkbox -->

            <CheckBox
                android:id="@+id/shang_checkbox"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingBottom="@dimen/margin_10dp"
                android:paddingLeft="@dimen/margin_15dp"
                android:paddingRight="@dimen/margin_15dp"
                android:paddingTop="@dimen/margin_10dp"
                android:src="@drawable/shopcart_selected" />

            <!-- 商店明晨 -->
            <TextView
                android:id="@+id/shangjia"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawableLeft="@drawable/shopcart_shop"
                android:drawablePadding="@dimen/padding_5dp"
                android:padding="@dimen/padding_10dp"
                android:text="宝儿家服装"
                android:textColor="@color/cblack" />

        </LinearLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_vertical">


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

            <View
                android:layout_width="match_parent"
                android:layout_height="@dimen/margin_1dp"
                android:background="@color/background_color" />


            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal">
                <!-- 商品 checkbox -->
                <CheckBox
                    android:id="@+id/pin_checkbox"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/margin_15dp"
                    android:src="@drawable/shopcart_selected" />
                <!-- 商品图片 -->
                <com.facebook.drawee.view.SimpleDraweeView
                    android:id="@+id/image"
                    android:layout_width="60dp"
                    android:layout_height="60dp"
                    android:layout_margin="@dimen/margin_10dp" />

                <LinearLayout
                    android:layout_width="0dp"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/title"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/cblack"
                        android:textSize="@dimen/common_font_size_12" />

                    <TextView
                        android:id="@+id/price"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="¥185"
                        android:textColor="@color/main_red_text"
                        android:textSize="@dimen/common_font_size_14" />

                    <com.example.cz.chenzhe20180108.CustCrom
                        android:id="@+id/cust"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"></com.example.cz.chenzhe20180108.CustCrom>
                </LinearLayout>

                <View
                    android:layout_width="@dimen/margin_1dp"
                    android:layout_height="match_parent"
                    android:layout_marginBottom="@dimen/padding_10dp"
                    android:layout_marginTop="@dimen/padding_10dp"
                    android:background="@color/splitline_color" />

                <ImageView
                    android:id="@+id/item_del"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:padding="@dimen/margin_20dp"
                    android:src="@drawable/shopcart_delete" />

            </LinearLayout>


        </LinearLayout>

    </LinearLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="@dimen/margin_1dp"
        android:background="@color/background_color" />
</LinearLayout>
custcrom自定义view的布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal">

    <Button
        android:id="@+id/revserse"
        android:layout_width="10dp"
        android:layout_height="wrap_content"
        android:background="#00FFFFFF"
        android:text="-" />

    <EditText
        android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:inputType="number"
        android:text="1" />

    <Button
        android:id="@+id/add"
        android:layout_width="10dp"
        android:layout_height="wrap_content"
        android:background="#00FFFFFF"
        android:text="+" />
</LinearLayout>
mainactivity页面:
public class MainActivity extends AppCompatActivity implements XiangQingView, AddView {

    XiangQingPersenter persenter = new XiangQingPersenter(this);
    AddPersenter addpersenter = new AddPersenter(this);
    @BindView(R.id.simple)
    SimpleDraweeView simple;
    @BindView(R.id.title)
    TextView title;
    @BindView(R.id.sub)
    TextView sub;
    @BindView(R.id.youhui)
    TextView youhui;
    @BindView(R.id.price)
    TextView price;
    @BindView(R.id.gowuche)
    Button gowuche;
    @BindView(R.id.addgowuche)
    Button addgowuche;

    List<XiangQingBean.DataBean> list = new ArrayList<XiangQingBean.DataBean>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        persenter.getData("71", "android");
    }

    @Override
    public void success(XiangQingBean bean) {
        list.add(bean.getData());
        Toast.makeText(MainActivity.this, bean.getData().getTitle() + "", Toast.LENGTH_SHORT).show();
        String[] split = bean.getData().getImages().split("\\|");
        simple.setImageURI(Uri.parse(split[0]));
        title.setText(bean.getData().getTitle());
        sub.setText(bean.getData().getSubhead());
        youhui.setText("¥:" + bean.getData().getBargainPrice());
        price.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        price.setText("¥:" + bean.getData().getPrice());
    }

    @Override
    public void success(AddBean bean) {
        Toast.makeText(MainActivity.this, bean.getMsg()+"", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void failuer(String e) {
        Toast.makeText(MainActivity.this, "错误", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        persenter.sdsd();
    }

    @OnClick({R.id.gowuche, R.id.addgowuche})
    public void onClick(View v) {
        switch (v.getId()) {
            default:
                break;
            case R.id.gowuche:
                Intent intent = new Intent(MainActivity.this, GoWuCheActivity.class);
                startActivity(intent);
                break;
            case R.id.addgowuche:
                addpersenter.getData("101", list.get(0).getPid() + "", "android");
                break;
        }
    }
}
gowucheactivity页面:
public class GoWuCheActivity extends AppCompatActivity implements GoWuCheView, View.OnClickListener {

    GoWuChePersenter persenter = new GoWuChePersenter(this);
    @BindView(R.id.third_recyclerview)
    RecyclerView thirdRecyclerview;
    @BindView(R.id.third_allselect)
    CheckBox thirdAllselect;
    @BindView(R.id.third_totalprice)
    TextView thirdTotalprice;
    @BindView(R.id.third_totalnum)
    TextView thirdTotalnum;
    @BindView(R.id.third_submit)
    TextView thirdSubmit;
    @BindView(R.id.third_pay_linear)
    LinearLayout thirdPayLinear;

    private MyAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_go_wu_che);
        ButterKnife.bind(this);
        persenter.getData("101", "android");

        thirdAllselect.setOnClickListener(this);
        adapter = new MyAdapter(this);
        LinearLayoutManager manager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);

        thirdRecyclerview.setLayoutManager(manager);
        //recyclerview里添加数据
        thirdRecyclerview.setAdapter(adapter);
        Log.e("数据", adapter.toString());
        //适配器的事件
        adapter.setListener(new MyAdapter.UpdateUiListener() {

            @Override
            public void setToal(String total, String num, boolean allcheck) {
                thirdAllselect.setChecked(allcheck);
                thirdTotalnum.setText(num);
                thirdTotalprice.setText(total);
            }
        });
    }

    @Override
    public void success(GoWuCheBean bean) {
        adapter.add(bean);
        Toast.makeText(GoWuCheActivity.this, bean.getData().get(1).getList().get(0).getTitle() + "", Toast.LENGTH_SHORT).show();
    }

    @Override
    public void failuer(String e) {
        Toast.makeText(GoWuCheActivity.this, "错误", Toast.LENGTH_SHORT).show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        persenter.assaassa();
    }

    @Override
    public void onClick(View view) {
        adapter.selectAll(thirdAllselect.isChecked());
    }
}

myadapter适配器页面:
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.MyViewHolder> {

    Context context;

    List<GoWuCheBean.DataBean.ListBean> list;



    List<String> shuju = new ArrayList<>();



    HashMap<String, String> map = new HashMap<>();



    private List<GoWuCheBean.DataBean.ListBean> first;



    public MyAdapter(Context context) {

        this.context = context;

    }



    public void add(GoWuCheBean bean) {

        if (this.list == null) {

            this.list = new ArrayList<>();

        }

        for (GoWuCheBean.DataBean shop : bean.getData()) {

            map.put(shop.getSellerid(), shop.getSellerName());

            for (int i = 0; i < shop.getList().size(); i++) {

                this.list.add(shop.getList().get(i));

            }

        }

        setFirst(this.list);

        notifyDataSetChanged();

    }



    public void setFirst(List<GoWuCheBean.DataBean.ListBean> first) {

        if (list.size() > 0) {

            list.get(0).setIsFirst(1);

            for (int i = 1; i < list.size(); i++) {

                if (list.get(i).getSellerid() == list.get(i - 1).getSellerid()) {

                    list.get(i).setIsFirst(2);

                } else {

                    list.get(i).setIsFirst(1);

                }

            }

        }

    }



    @Override

    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(context).inflate(R.layout.adapter_layout, null);



        return new MyViewHolder(view);

    }



    @Override

    public void onBindViewHolder(final MyViewHolder holder, final int position) {

        if (list.get(position).getIsFirst() == 1) {

            holder.shangCheckbox.setChecked(list.get(position).isShopSelected());

            holder.shangjia.setVisibility(View.VISIBLE);

            holder.shangCheckbox.setVisibility(View.VISIBLE);

            holder.shangjia.setText(map.get(String.valueOf(list.get(position).getSellerid())));

        } else {

            //否则隐藏起来

            holder.shangjia.setVisibility(View.GONE);

            holder.shangCheckbox.setVisibility(View.GONE);

        }



//        holder.shangjia.setText(shuju.get(position));

        holder.pinCheckbox.setChecked(list.get(position).isItemSelected());

        String[] split = list.get(position).getImages().split("\\|");

        holder.image.setImageURI(Uri.parse(split[0]));

        holder.title.setText(list.get(position).getTitle());

        holder.price.setText("¥:" + list.get(position).getPrice());

        holder.cust.setEditText(list.get(position).getNum());

//        holder.content.setEditText(list.get(position).getNum());

        holder.shangCheckbox.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                list.get(position).setShopSelected(holder.shangCheckbox.isChecked());

                //循环商品有几件循环几次

                for (int i = 0; i < list.size(); i++) {

                    //判断商品是否全选中,如果选中所有的全选

                    if (list.get(position).getSellerid() == list.get(i).getSellerid()) {

                        list.get(i).setItemSelected(holder.shangCheckbox.isChecked());

                    }

                }

                //刷新适配器

                notifyDataSetChanged();

                //计算总价和输两天

                sum(list);

            }

        });

        holder.pinCheckbox.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                list.get(position).setItemSelected(holder.pinCheckbox.isChecked());

                //循环

                for (int i = 0; i < list.size(); i++) {

                    for (int j = 0; j < list.size(); j++) {

                        //判断商品是否点钟

                        if (list.get(i).getSellerid() == list.get(j).getSellerid() && !list.get(j).isItemSelected()) {

                            //未点中

                            list.get(i).setShopSelected(false);

                            break;

                        } else {

                            //否则点钟

                            list.get(i).setShopSelected(true);

                        }

                    }

                    //循环判断后,刷新适配

                    notifyDataSetChanged();

                    //进行计算总价和数量

                    sum(list);

                }

            }

        });

        //删除的点击事件

        holder.itemDel.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                //list删除数据

                list.remove(position);

                setFirst(list);

                //删除完后刷新数据

                notifyDataSetChanged();

                //刷新完数据后进行计算总价和数量

                sum(list);

            }

        });

        //数量的

        holder.cust.setListener(new CustCrom.ClickListener() {

            @Override

            public void click(int count) {

                list.get(position).setNum(count);

                //刷新适配器

                notifyDataSetChanged();

                sum(list);

            }



        });

    }



    private void sum(List<GoWuCheBean.DataBean.ListBean> list) {

        int totalNum = 0;

        float totalMoney = 0.0f;

        boolean allCheck = true;

        for (int i = 0; i < list.size(); i++) {

            if (list.get(i).isItemSelected()) {

                totalNum += list.get(i).getNum();

                totalMoney += list.get(i).getNum() * list.get(i).getPrice();

            } else {

                allCheck = false;

            }

        }

        //list.size()==0?false:allCheck  这是全选后再把数据都删除后,全选按钮还是全选的时候写的

        listener.setToal(totalMoney + "", totalNum + "", list.size() == 0 ? false : allCheck);

    }



    @Override

    public int getItemCount() {

        return list == null ? 0 : list.size();

    }





    public class MyViewHolder extends RecyclerView.ViewHolder {

        @BindView(R.id.shang_checkbox)

        CheckBox shangCheckbox;

        @BindView(R.id.shangjia)

        TextView shangjia;

        @BindView(R.id.pin_checkbox)

        CheckBox pinCheckbox;

        @BindView(R.id.image)

        SimpleDraweeView image;

        @BindView(R.id.title)

        TextView title;

        @BindView(R.id.price)

        TextView price;

        @BindView(R.id.item_del)

        ImageView itemDel;

        @BindView(R.id.cust)

        CustCrom cust;





        public MyViewHolder(View view) {

            super(view);

            ButterKnife.bind(this, view);

        }

    }



    private UpdateUiListener listener;



    public void setListener(UpdateUiListener listener) {

        this.listener = listener;

    }



    public void selectAll(boolean check) {

        for (int i = 0; i < list.size(); i++) {

            list.get(i).setShopSelected(check);

            list.get(i).setItemSelected(check);

        }

        notifyDataSetChanged();

        sum(list);

    }





    public interface UpdateUiListener {

        public void setToal(String total, String num, boolean allcheck);

    }

}





custcrom自定义view页面:
public class CustCrom extends LinearLayout {
    private int mCount = 1;
    private Button revserse;
    private Button add;
    private EditText editText;

    public CustCrom(Context context) {
        super(context);
    }

    public CustCrom(final Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        View view = LayoutInflater.from(context).inflate(R.layout.item_custcrom, null, false);
        revserse = (Button) view.findViewById(R.id.revserse);
        add = (Button) view.findViewById(R.id.add);
        editText = (EditText) view.findViewById(R.id.content);
        revserse.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    //减后在输入框里的数字是多少
                    String content = editText.getText().toString().trim();
                    int count = Integer.valueOf(content);
                    //判断数量是否大于1,如果大于一的话可以减减,如果等于一的话则不再往下减了
                    if (count > 1) {
                        mCount = count - 1;
                        //输入框的数字
                        editText.setText(mCount + "");
                        if (listener != null) {
                            listener.click(mCount);
                        }
                    } else if (count == 1) {
                        Toast.makeText(context, "最小为1", Toast.LENGTH_SHORT).show();
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        //加号点击事件
        add.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                try {
                    //可以一直加下去
                    String content = editText.getText().toString().trim();
                    int count = Integer.valueOf(content) + 1;
                    mCount = count;
                    editText.setText(count + "");
                    if (listener != null) {
                        listener.click(count);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        //输入框
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
        addView(view);
    }

    public CustCrom(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

    }

    public void setEditText(int num) {
        if (editText != null) {
            editText.setText(num + "");
        }
    }

    private ClickListener listener;

    public void setListener(ClickListener listener) {
        this.listener = listener;
    }

    public interface ClickListener {
        public void click(int count);
    }
}
新建一个文件myapp,myapp要在配置权限的application下,新写一个name:
public class MyApp extends Application {

    public static Inters inters;

    @Override
    public void onCreate() {
        super.onCreate();
        Fresco.initialize(this);
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://www.zhaoapi.cn")
                .addConverterFactory(GsonConverterFactory.create())
                .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
                .build();
        inters = retrofit.create(Inters.class);
    }
}





Bean类,在Bean还要添加三个东西;就在最底下的集合里
package com.example.cz.lianxigowuche.Bean;

import java.util.List;

/**
 * Created by CZ on 2018/1/8.
 */

public class Bean {
    /**
     * msg : 请求成功
     * code : 0
     * data : [{"list":[{"bargainPrice":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg","num":1,"pid":47,"price":111,"pscid":39,"selected":0,"sellerid":3,"subhead":"碳黑色 32GB 全网通 官方标配   1件","title":"锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通"}],"sellerName":"商家3","sellerid":"3"},{"list":[{"bargainPrice":399,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/1439822107.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5887/201/859509257/69994/6bde9bf6/59224c24Ne854e14c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5641/233/853609022/57374/5c73d281/59224c24N3324d5f4.jpg!q70.jpg","num":2,"pid":86,"price":777,"pscid":85,"selected":0,"sellerid":7,"subhead":"满2件,总价打6.50折","title":"Gap男装 休闲舒适简约水洗五袋直筒长裤紧身牛仔裤941825 深灰色 33/32(175/84A)"}],"sellerName":"商家7","sellerid":"7"},{"list":[{"bargainPrice":11800,"createtime":"2017-10-03T23:53:28","detailUrl":"https://mitem.jd.hk/ware/view.action?wareId=1988853309&cachekey=1acb07a701ece8d2434a6ae7fa6870a1","images":"https://m.360buyimg.com/n0/jfs/t6130/97/1370670410/180682/1109582a/593276b1Nd81fe723.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5698/110/2617517836/202970/c9388feb/593276b7Nbd94ef1f.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5815/178/2614671118/51656/7f52d137/593276c7N107b725a.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5878/60/2557817477/30873/4502b606/593276caN5a7d6357.jpg!q70.jpg","num":4,"pid":71,"price":32999,"pscid":40,"selected":0,"sellerid":15,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"}],"sellerName":"商家15","sellerid":"15"},{"list":[{"bargainPrice":111.99,"createtime":"2017-10-14T21:39:05","detailUrl":"https://item.m.jd.com/product/4719303.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9004/210/1160833155/647627/ad6be059/59b4f4e1N9a2b1532.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7504/338/63721388/491286/f5957f53/598e95f1N7f2adb87.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7441/10/64242474/419246/adb30a7d/598e95fbNd989ba0a.jpg!q70.jpg","num":2,"pid":1,"price":118,"pscid":1,"selected":0,"sellerid":17,"subhead":"每个中秋都不能简单,无论身在何处,你总需要一块饼让生活更圆满,京东月饼让爱更圆满京东自营,闪电配送,更多惊喜,快用手指戳一下","title":"北京稻香村 稻香村中秋节月饼 老北京月饼礼盒655g"}],"sellerName":"商家17","sellerid":"17"}]
     */

    private String msg;
    private String code;
    private List<DataBean> data;

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public List<DataBean> getData() {
        return data;
    }

    public void setData(List<DataBean> data) {
        this.data = data;
    }

    public static class DataBean {
        /**
         * list : [{"bargainPrice":1599,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg","num":1,"pid":47,"price":111,"pscid":39,"selected":0,"sellerid":3,"subhead":"碳黑色 32GB 全网通 官方标配   1件","title":"锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通"}]
         * sellerName : 商家3
         * sellerid : 3
         */

        private String sellerName;
        private String sellerid;
        private List<ListBean> list;

        public String getSellerName() {
            return sellerName;
        }

        public void setSellerName(String sellerName) {
            this.sellerName = sellerName;
        }

        public String getSellerid() {
            return sellerid;
        }

        public void setSellerid(String sellerid) {
            this.sellerid = sellerid;
        }

        public List<ListBean> getList() {
            return list;
        }

        public void setList(List<ListBean> list) {
            this.list = list;
        }

        public static class ListBean {
            /**
             * bargainPrice : 1599.0
             * createtime : 2017-10-14T21:48:08
             * detailUrl : https://item.m.jd.com/product/1993026402.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends
             * images : https://m.360buyimg.com/n0/jfs/t5863/302/8961270302/97126/41feade1/5981c81cNc1b1fbef.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t7003/250/1488538438/195825/53bf31ba/5981c57eN51e95176.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5665/100/8954482513/43454/418611a9/5981c57eNd5fc97ba.jpg!q70.jpg
             * num : 1
             * pid : 47
             * price : 111.0
             * pscid : 39
             * selected : 0
             * sellerid : 3
             * subhead : 碳黑色 32GB 全网通 官方标配   1件
             * title : 锤子 坚果Pro 特别版 巧克力色 酒红色 全网通 移动联通电信4G手机 双卡双待 碳黑色 32GB 全网通
             */

            private double bargainPrice;
            private String createtime;
            private String detailUrl;
            private String images;
            private int num;
            private int pid;
            private double price;
            private int pscid;
            private int selected;
            private int sellerid;
            private String subhead;
            private String title;

            // 1 显示商家  2 隐藏商家
            private int isFirst;


            // true 表示商家选中 false 相反
            private boolean shopSelected;


            // true 表示 当前商品是选中的 false 相反
            private boolean itemSelected;

            public int getIsFirst() {
                return isFirst;
            }

            public void setIsFirst(int isFirst) {
                this.isFirst = isFirst;
            }

            public boolean isShopSelected() {
                return shopSelected;
            }

            public void setShopSelected(boolean shopSelected) {
                this.shopSelected = shopSelected;
            }

            public boolean isItemSelected() {
                return itemSelected;
            }

            public void setItemSelected(boolean itemSelected) {
                this.itemSelected = itemSelected;
            }

            public double getBargainPrice() {
                return bargainPrice;
            }

            public void setBargainPrice(double bargainPrice) {
                this.bargainPrice = bargainPrice;
            }

            public String getCreatetime() {
                return createtime;
            }

            public void setCreatetime(String createtime) {
                this.createtime = createtime;
            }

            public String getDetailUrl() {
                return detailUrl;
            }

            public void setDetailUrl(String detailUrl) {
                this.detailUrl = detailUrl;
            }

            public String getImages() {
                return images;
            }

            public void setImages(String images) {
                this.images = images;
            }

            public int getNum() {
                return num;
            }

            public void setNum(int num) {
                this.num = num;
            }

            public int getPid() {
                return pid;
            }

            public void setPid(int pid) {
                this.pid = pid;
            }

            public double getPrice() {
                return price;
            }

            public void setPrice(double price) {
                this.price = price;
            }

            public int getPscid() {
                return pscid;
            }

            public void setPscid(int pscid) {
                this.pscid = pscid;
            }

            public int getSelected() {
                return selected;
            }

            public void setSelected(int selected) {
                this.selected = selected;
            }

            public int getSellerid() {
                return sellerid;
            }

            public void setSellerid(int sellerid) {
                this.sellerid = sellerid;
            }

            public String getSubhead() {
                return subhead;
            }

            public void setSubhead(String subhead) {
                this.subhead = subhead;
            }

            public String getTitle() {
                return title;
            }

            public void setTitle(String title) {
                this.title = title;
            }
        }
    }
}













  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值