仅供参考备用数据接口uid--71 http://www.zhaoapi.cn/product/getCarts?uid=91 依赖导入: implementation 'com.fynn.fluidlayout:fluidlayout:1.0' implementation 'com.hyman:flowlayout-lib:1.1.2' implementation 'com.jcodecraeer:xrecyclerview:1.5.9' implementation 'com.squareup.okhttp3:okhttp:3.11.0' //okhttp的log信息 implementation 'com.squareup.okhttp3:logging-interceptor:3.11.0' implementation 'com.google.code.gson:gson:2.8.5' implementation 'com.github.bumptech.glide:glide:4.7.1' } configurations.all { resolutionStrategy.eachDependency { DependencyResolveDetails details -> def requested = details.requested if (requested.group == 'com.android.support') { if (!requested.name.startsWith("multidex")) { details.useVersion '27.1.1' } } }
MainActivity页面实现:
import android.content.Intent; import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.view.ViewGroup; import android.widget.EditText; import android.widget.ImageView; import android.widget.TextView; import com.fynn.fluidlayout.FluidLayout; import com.zhy.view.flowlayout.FlowLayout; import com.zhy.view.flowlayout.TagAdapter; import com.zhy.view.flowlayout.TagFlowLayout; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private TextView cancel; private EditText search; private TagFlowLayout hot_tag; private FluidLayout liushi; private List<String> list; private ImageView img; private ListAdapter listAdapter; private String[] searfind ={"小洗衣机 全自动", "斜挎小包女", "情人节", "思婉妮可可汉堡气垫", "春秋长袖连衣裙 中长款", "香缇卡隔离防晒隔离霜遮瑕", "reveur 洗发水", "手机万能贴", "holdlive水墨眼影 ", "迷你小电饭锅"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initView(); initClick(); } private void initView() { img = findViewById(R.id.img); cancel = findViewById(R.id.cancel); search = findViewById(R.id.edittext); hot_tag = findViewById(R.id.hot_tag); liushi = findViewById(R.id.liushi); list = new ArrayList<>(); list.add("女士包"); list.add("鲜花99"); list.add("鲜花"); list.add("速腾车钥匙套"); list.add("速腾车钥匙"); list.add("手机"); list.add("rio鸡尾酒"); list.add("眼镜腿防过敏套"); list.add("包眼睛腿儿"); listAdapter = new ListAdapter(list); hot_tag.setAdapter(listAdapter); for (int i = 0; i < searfind.length; i++) { FluidLayout.LayoutParams params = new FluidLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ); params.setMargins(12, 12, 12, 12); TextView textView = new TextView(this); textView.setText(searfind[i]); textView.setTextColor(Color.BLACK); textView.setBackgroundResource(R.drawable.sousuoback); liushi.addView(textView, params); } } private void initClick() { img.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { String sear = search.getText().toString(); if (!TextUtils.isEmpty(sear)) { list.add(sear); listAdapter.notifyDataChanged(); } } }); hot_tag.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() { @Override public boolean onTagClick(View view, int position, FlowLayout parent) { Intent intent =new Intent(MainActivity.this,TwoActivity.class); startActivity(intent); return true; } }); } class ListAdapter extends TagAdapter<String>{ public ListAdapter(List<String> datas) { super(datas); } @Override public View getView(FlowLayout parent, int position, String s) { TextView textView = new TextView(MainActivity.this); textView.setText(s); textView.setBackgroundResource(R.drawable.sousuoback); return textView; } } } main。xml 布局基础
<?xml version="1.0" encoding="utf-8"?> <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" tools:context=".MainActivity" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="#F2F2F2" android:gravity="center_vertical"> <ImageView android:id="@+id/img" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:src="@drawable/order_find"/> <EditText android:id="@+id/edittext" android:layout_width="0dp" android:layout_weight="8" android:layout_height="wrap_content" android:background="@drawable/sousuoback"/> <TextView android:id="@+id/cancel" android:layout_width="0dp" android:layout_weight="2" android:layout_height="wrap_content" android:gravity="center" android:text="取消" android:textSize="28sp"/> </LinearLayout> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="历史搜索" android:textSize="32sp"/> <com.zhy.view.flowlayout.TagFlowLayout android:id="@+id/hot_tag" android:padding="16dp" app:max_select="1" android:layout_width="match_parent" android:layout_height="wrap_content"/> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="搜索发现" android:textSize="32sp"/> <com.fynn.fluidlayout.FluidLayout android:id="@+id/liushi" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
TwoActivity 页面功能实现:
import android.content.Intent; import android.provider.SyncStateContract; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.support.v7.widget.LinearLayoutManager; import android.view.View; import android.widget.CheckBox; import android.widget.TextView; import android.widget.Toast; import com.jcodecraeer.xrecyclerview.XRecyclerView; import java.util.HashMap; import java.util.List; import yangxinlang.bawei.com.moniyuekao.adapter.CartAdapter; import yangxinlang.bawei.com.moniyuekao.adapter.CartAllCheckboxListener; import yangxinlang.bawei.com.moniyuekao.bean.CartBean; import yangxinlang.bawei.com.moniyuekao.net.Constants; import yangxinlang.bawei.com.moniyuekao.p.CartPresenter; import yangxinlang.bawei.com.moniyuekao.v.IcartView; public class TwoActivity extends AppCompatActivity implements IcartView, CartAllCheckboxListener { private CartPresenter cartPresenter; private XRecyclerView xRecyclerView; private CartAdapter cartAdapter; private List<CartBean.DataBean> list; private CheckBox allCheckbox; private TextView totalPriceTv; private int page = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_two); initView(); initData(); } private void initView() { xRecyclerView = findViewById(R.id.cartGV); allCheckbox = findViewById(R.id.allCheckbox); xRecyclerView.setLayoutManager(new LinearLayoutManager(this)); totalPriceTv = findViewById(R.id.totalpriceTv); xRecyclerView.setLoadingMoreEnabled(true); xRecyclerView.setLoadingListener(new XRecyclerView.LoadingListener() { @Override public void onRefresh() {//下拉刷新 page = 1; loadData();//子线程 // xRecyclerView.refreshComplete(); } @Override public void onLoadMore() {//加载更多 page++; loadData(); // xRecyclerView.loadMoreComplete(); } }); allCheckbox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (allCheckbox.isChecked()) {// if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { list.get(i).setSelected(true); for (int i1 = 0; i1 < list.get(i).getList().size(); i1++) { list.get(i).getList().get(i1).setSelected(true); } } } } else { if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { list.get(i).setSelected(false); for (int i1 = 0; i1 < list.get(i).getList().size(); i1++) { list.get(i).getList().get(i1).setSelected(false); } } } // totalPrice = 0; } cartAdapter.notifyDataSetChanged();//全部刷新 totalPrice(); } }); } private void loadData() { HashMap<String, String> params = new HashMap<>(); params.put("uid", "91"); params.put("page", page + ""); cartPresenter = new CartPresenter(this); cartPresenter.getCarts(params, Constants.GETCARTS); } private void initData() { loadData(); } public void buy(View view) { Intent intent = new Intent(TwoActivity.this, TobToActivity.class); startActivity(intent); } @Override public void notifyAllCheckboxStatus() { StringBuilder stringBuilder = new StringBuilder(); if (cartAdapter != null) { for (int i = 0; i < cartAdapter.getCartList().size(); i++) { stringBuilder.append(cartAdapter.getCartList().get(i).isSelected()); for (int i1 = 0; i1 < cartAdapter.getCartList().get(i).getList().size(); i1++) { stringBuilder.append(cartAdapter.getCartList().get(i).getList().get(i1).isSelected()); } } } System.out.println("sb=====" + stringBuilder.toString()); //truetruefalsetruefalse if (stringBuilder.toString().contains("false")) { allCheckbox.setChecked(false); // totalPrice = 0; } else { allCheckbox.setChecked(true); } totalPrice();//计算总价 } private void totalPrice() { double totalPrice = 0; for (int i = 0; i < cartAdapter.getCartList().size(); i++) { for (int i1 = 0; i1 < cartAdapter.getCartList().get(i).getList().size(); i1++) { //计算总价的关键代码块 if (cartAdapter.getCartList().get(i).getList().get(i1).isSelected()) { CartBean.DataBean.ListBean listBean = cartAdapter.getCartList().get(i).getList().get(i1); totalPrice += listBean.getBargainPrice() * listBean.getTotalNum(); } } } totalPriceTv.setText("总价:¥" + totalPrice); } @Override public void success(CartBean cartBean) { if (cartBean != null && cartBean.getData() != null) { if (page == 1) { list = cartBean.getData(); cartAdapter = new CartAdapter(this, list); xRecyclerView.setAdapter(cartAdapter); xRecyclerView.refreshComplete();//把下拉刷新的进度view隐藏掉 } else { if (cartAdapter != null) { cartAdapter.addPageData(cartBean.getData()); } xRecyclerView.loadMoreComplete();// } cartAdapter.setCartAllCheckboxListener(this); } } @Override public void failure(String msg) { Toast.makeText(this, msg, Toast.LENGTH_SHORT).show(); } }
Two xml 布局实现:
<?xml version="1.0" encoding="utf-8"?> <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="wrap_content" tools:context=".TwoActivity"> <com.jcodecraeer.xrecyclerview.XRecyclerView android:id="@+id/cartGV" android:layout_above="@+id/cart_bottom_layout" android:layout_alignParentTop="true" android:layout_width="match_parent" android:layout_height="wrap_content"/> <RelativeLayout android:id="@+id/cart_bottom_layout" android:padding="5dp" android:background="@android:color/darker_gray" android:layout_alignParentBottom="true" android:layout_width="match_parent" android:layout_height="wrap_content"> <CheckBox android:layout_centerVertical="true" android:id="@+id/allCheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/totalpriceTv" android:textColor="#ffffff" android:layout_centerVertical="true" android:layout_toRightOf="@+id/allCheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="总价:"/> <Button android:id="@+id/buy" android:onClick="buy" android:layout_alignParentRight="true" android:text="去结算" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </RelativeLayout> </RelativeLayout>
OkHttp 网络请求实现:
OkhttpUtils:
import java.io.File; import java.io.IOException; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; import okhttp3.Call; import okhttp3.Callback; import okhttp3.FormBody; import okhttp3.MediaType; import okhttp3.MultipartBody; import okhttp3.OkHttpClient; import okhttp3.Request; import okhttp3.RequestBody; import okhttp3.Response; import okhttp3.logging.HttpLoggingInterceptor; public class OkhttpUtils { private OkHttpClient okHttpClient; private static OkhttpUtils okhttpUtils; public OkhttpUtils() { HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); okHttpClient=new OkHttpClient.Builder() .addInterceptor(loggingInterceptor) .connectTimeout(5,TimeUnit.SECONDS) .writeTimeout(5, TimeUnit.SECONDS) .readTimeout(5,TimeUnit.SECONDS) .build(); } public static OkhttpUtils getInstance() { if (okhttpUtils==null){ synchronized (OkhttpUtils.class){ if (okhttpUtils==null){ okhttpUtils=new OkhttpUtils(); } } } return okhttpUtils; } public void getData(String url, HashMap<String, String> params, final RequestCallback requestCallback){ StringBuilder builder = new StringBuilder(); String allurl=""; for (Map.Entry<String, String> stringStringEntry : params.entrySet()) { builder.append("?").append(stringStringEntry.getKey()).append("=").append(stringStringEntry.getValue()).append("&"); } allurl = url + builder.toString().substring(0, builder.length() - 1); System.out.println("url:" + allurl); final Request request = new Request.Builder() .url(allurl).get().build(); okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { if (requestCallback!=null){ requestCallback.failure(call, e); } } @Override public void onResponse(Call call, Response response) throws IOException { if (requestCallback!=null){ requestCallback.onResponse(call, response); } } }); } public void getPost(String url, HashMap<String, String> prams, final RequestCallback requestCallback) { FormBody.Builder builder = new FormBody.Builder(); if (prams != null && prams.size() > 0) { for (Map.Entry<String, String> stringStringEntry : prams.entrySet()) { builder.add(stringStringEntry.getKey(), stringStringEntry.getValue()); } } Request request = new Request.Builder() .url(url).post(builder.build()).build(); okHttpClient.newCall(request).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { if (requestCallback!=null){ requestCallback.failure(call, e); } } @Override public void onResponse(Call call, Response response) throws IOException { if (requestCallback!=null){ requestCallback.onResponse(call, response); } } }); } public void uploadFile(String url, HashMap<String, Object> params, final RequestCallback requestCallback) { MultipartBody.Builder builder1 = new MultipartBody.Builder(); builder1.setType(MultipartBody.FORM); for (Map.Entry<String, Object> stringObjectEntry : params.entrySet()) { String key = stringObjectEntry.getKey(); Object value = stringObjectEntry.getValue(); if (value instanceof File){//如果value类型是文件类型 File file = (File) value; //创建文件请求体 RequestBody requestBody = RequestBody.create(MediaType.parse("application/octet-stream"), file); builder1.addFormDataPart(key,file.getName(),requestBody); }else { builder1.addFormDataPart(key, (String) value); } } Request request1 = new Request.Builder().addHeader("","").post(builder1.build()).url(url).build(); okHttpClient.newCall(request1).enqueue(new Callback() { @Override public void onFailure(Call call, IOException e) { if (requestCallback != null) { requestCallback.failure(call, e); } URLEncoder.encode("url"); } //请求成功 @Override public void onResponse(Call call, Response response) throws IOException { if (requestCallback != null) { requestCallback.onResponse(call, response); } } }); } }
RequestCallback:
import java.io.IOException; import okhttp3.Call; import okhttp3.Response; public interface RequestCallback { void failure(Call call, IOException e); void onResponse(Call call, Response response); }
SpaceItemDecoration:
import android.graphics.Rect; import android.support.v7.widget.RecyclerView; import android.view.View; public class SpaceItemDecoration extends RecyclerView.ItemDecoration { private int space; public SpaceItemDecoration(int space) { this.space = space; } @Override public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) { if(parent.getChildPosition(view) != 0) outRect.top = space; } }
Constants:
public class Constants { public static final String GETCARTS = "http://www.zhaoapi.cn/product/getCarts";//获取购物车 public static final String CREATE_ORDER = "https://www.zhaoapi.cn/product/createOrder";//获取购物车 public static final String ADD_CART = "https://www.zhaoapi.cn/product/addCart";//添加购物车 }
mvp架构实现:
CartModel:
import android.os.Handler; import android.text.TextUtils; import com.google.gson.Gson; import java.io.IOException; import java.util.HashMap; import okhttp3.Call; import okhttp3.Response; import yangxinlang.bawei.com.moniyuekao.bean.CartBean; import yangxinlang.bawei.com.moniyuekao.net.OkhttpUtils; import yangxinlang.bawei.com.moniyuekao.net.RequestCallback; public class CartModel { Handler handler =new Handler(); public void getCarts(HashMap<String, String> params, String url, final CartCallback cartCallback) { OkhttpUtils.getInstance().getPost(url, params, new RequestCallback() { @Override public void failure(Call call, IOException e) { if (cartCallback != null) { cartCallback.fail("网络有异常,请稍后再试"); } } @Override public void onResponse(Call call, Response response) { try { String jsonResult = response.body().string(); if (!TextUtils.isEmpty(jsonResult)) { parseResult(jsonResult, cartCallback); } } catch (IOException e) { e.printStackTrace(); } } }); } /** * 解析购物车数据 * * @param jsonResult * @param cartCallback */ private void parseResult(String jsonResult, final CartCallback cartCallback) { final CartBean cartBean = new Gson().fromJson(jsonResult, CartBean.class); if (cartCallback != null && cartBean != null) {//代码规范,代码优化 handler.post(new Runnable() { @Override public void run() { cartCallback.success(cartBean); } }); } } public interface CartCallback { void success(CartBean cartBean);//回调bean对象给presenter void fail(String msg);//异常信息回调 } }
IcartView:
import yangxinlang.bawei.com.moniyuekao.bean.CartBean; public interface IcartView { void success(CartBean cartBean); void failure(String msg); }
CartPresenter:
import java.util.HashMap; import yangxinlang.bawei.com.moniyuekao.bean.CartBean; import yangxinlang.bawei.com.moniyuekao.m.CartModel; import yangxinlang.bawei.com.moniyuekao.v.IcartView; public class CartPresenter { private CartModel cartModel; private IcartView icartView; public CartPresenter(IcartView icartView) { cartModel =new CartModel(); attachView(icartView); } /** * 绑定view到presenter * @param icartView */ public void attachView(IcartView icartView){ this.icartView = icartView; } public void getCarts(HashMap<String,String> params, String url){ cartModel.getCarts(params, url, new CartModel.CartCallback() { @Override public void success(CartBean cartBean) { if (icartView!=null){ icartView.success(cartBean); } } @Override public void fail(String msg) { if (icartView!=null){ icartView.failure(msg); } } }); } /** * 解除绑定,把view和presenter解绑,避免内存泄漏 */ public void detachView(){ this.icartView = null; } } adapter适配器功能实现:
CartAdapter:
import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.TextView; import java.util.List; import yangxinlang.bawei.com.moniyuekao.R; import yangxinlang.bawei.com.moniyuekao.bean.CartBean; public class CartAdapter extends RecyclerView.Adapter<CartAdapter.CartViewHolder> implements CartCheckListener { private Context mContext; private List<CartBean.DataBean> cartList; private CartAllCheckboxListener allCheckboxListener; public CartAdapter(Context context, List<CartBean.DataBean> list) { mContext = context; cartList = list; } public void addPageData(List<CartBean.DataBean> list){ if (cartList!=null){ cartList.addAll(list); notifyDataSetChanged(); } } //暴露给购物车页面进行回调 public void setCartAllCheckboxListener(CartAllCheckboxListener cartAllCheckboxListener) { allCheckboxListener = cartAllCheckboxListener; } @NonNull @Override public CartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(mContext).inflate(R.layout.cart_item_layout, parent, false); CartViewHolder viewHolder = new CartViewHolder(itemView); return viewHolder; } @Override public void onBindViewHolder(@NonNull final CartViewHolder holder, final int position) { final CartBean.DataBean bean = cartList.get(position); holder.nameTv.setText(bean.getSellerName()); holder.checkBox.setChecked(bean.isSelected());//根据bean对象的ischecked属性,动态设置选中状态 // System.out.println("ischecked:" + bean.isChecked()); // holder.checkBox.setChecked(bean.isChecked()); holder.productXRV.setLayoutManager(new LinearLayoutManager(mContext)); final ProductAdapter productAdapter = new ProductAdapter(mContext, bean.getList()); holder.productXRV.setAdapter(productAdapter); productAdapter.setCheckListener(this); for (int i = 0; i < bean.getList().size(); i++) { if (!bean.getList().get(i).isSelected()){ holder.checkBox.setChecked(false); break;//跳出循环 }else{ holder.checkBox.setChecked(true); } } //设置商家的checkbox点击事件,逻辑:勾选则子列表全部勾选,取消则全部取消 holder.checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (holder.checkBox.isChecked()){ bean.setSelected(true); for (int i = 0; i < bean.getList().size(); i++) { bean.getList().get(i).setSelected(true); } }else{ bean.setSelected(false); for (int i = 0; i < bean.getList().size(); i++) { bean.getList().get(i).setSelected(false); } } notifyDataSetChanged(); if (allCheckboxListener!=null){ allCheckboxListener.notifyAllCheckboxStatus(); } } }); } /** * 暴露修改之后的最新的集合数据 * @return */ public List<CartBean.DataBean> getCartList() { return cartList; } @Override public int getItemCount() { return cartList.size() == 0 ? 0 : cartList.size(); } /** * 刷新适配器的回调 */ @Override public void notifyParent() { notifyDataSetChanged(); if (allCheckboxListener!=null){ allCheckboxListener.notifyAllCheckboxStatus(); } } // @Override // public void notifyParent() { // notifyDataSetChanged(); // } public class CartViewHolder extends RecyclerView.ViewHolder { private CheckBox checkBox; private TextView nameTv; private RecyclerView productXRV; public CartViewHolder(View itemView) { super(itemView); checkBox = itemView.findViewById(R.id.sellerCheckbox); nameTv = itemView.findViewById(R.id.sellerNameTv); productXRV = itemView.findViewById(R.id.productXRV); } } }
cart_item_layout:布局实现
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:padding="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:id="@+id/sellerCheckbox" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <TextView android:id="@+id/sellerNameTv" android:text="商家" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:background="#999999"/> <android.support.v7.widget.RecyclerView android:id="@+id/productXRV" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
ProductAdapter:
import android.content.Context; import android.support.annotation.NonNull; import android.support.v7.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; import android.widget.ImageView; import android.widget.TextView; import com.bumptech.glide.Glide; import java.util.List; import yangxinlang.bawei.com.moniyuekao.R; import yangxinlang.bawei.com.moniyuekao.bean.CartBean; import yangxinlang.bawei.com.moniyuekao.widget.MyJIaJianView; public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.CartViewHolder> { private Context mContext; private List<CartBean.DataBean.ListBean> listBeanList; private CartCheckListener checkListener;//接口回调引用 private CartAllCheckboxListener cartAllCheckboxListener; public ProductAdapter(Context context, List<CartBean.DataBean.ListBean> list) { mContext = context; listBeanList = list; } /** * 暴露给调用者去进行回调:对checklisener进行初始化 * @param checkListener */ public void setCheckListener(CartCheckListener checkListener) { this.checkListener = checkListener; } public void setCartAllCheckboxListener(CartAllCheckboxListener cartAllCheckboxListener) { this.cartAllCheckboxListener = cartAllCheckboxListener; } @NonNull @Override public CartViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View itemView = LayoutInflater.from(mContext).inflate(R.layout.product_item_layout, parent, false); CartViewHolder viewHolder = new CartViewHolder(itemView); return viewHolder; } @Override public void onBindViewHolder(@NonNull final CartViewHolder holder, int position) { final CartBean.DataBean.ListBean bean = listBeanList.get(position); holder.priceTv.setText("优惠价:¥" + bean.getBargainPrice()); holder.titleTv.setText(bean.getTitle()); String[] imgs = bean.getImages().split("\\|");//分割images,得到图片数组 //校验数组大小是否>0,防止空指针 if (imgs != null && imgs.length > 0) { Glide.with(mContext).load(imgs[0]).into(holder.productIv); } else { holder.productIv.setImageResource(R.mipmap.ic_launcher); } holder.checkBox.setChecked(bean.isSelected()); holder.myJIaJianView.setNumEt(bean.getTotalNum()); holder.myJIaJianView.setJiaJianListener(new MyJIaJianView.JiaJianListener() { @Override public void getNum(int num) { bean.setTotalNum(num); if (checkListener!=null){ checkListener.notifyParent();//通知一级列表适配器刷新 } } }); holder.checkBox.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (holder.checkBox.isChecked()) {//选中 bean.setSelected(true); } else {//非选中 bean.setSelected(false); } if (checkListener!=null){ checkListener.notifyParent();//通知一级列表适配器刷新 } } }); // holder.checkBox.setOnClickListener(new View.OnClickListener() { // @Override // public void onClick(View v) { // if (holder.checkBox.isChecked()){ // bean.setChecked(true); // }else{ // bean.setChecked(false); // } // // checkListener.notifyParent(); // } // }); } @Override public int getItemCount() { return listBeanList.size() == 0 ? 0 : listBeanList.size(); } public class CartViewHolder extends RecyclerView.ViewHolder { private CheckBox checkBox; private TextView titleTv, priceTv; private ImageView productIv; private MyJIaJianView myJIaJianView; public CartViewHolder(View itemView) { super(itemView); checkBox = itemView.findViewById(R.id.productCheckbox); titleTv = itemView.findViewById(R.id.title); priceTv = itemView.findViewById(R.id.price); productIv = itemView.findViewById(R.id.product_icon); myJIaJianView = itemView.findViewById(R.id.jiajianqi); } } }
product_item_layout商品布局:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <LinearLayout android:padding="10dp" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <CheckBox android:id="@+id/productCheckbox" android:layout_gravity="center" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <ImageView android:src="@mipmap/ic_launcher" android:id="@+id/product_icon" android:layout_width="80dp" android:layout_height="80dp"/> </LinearLayout> <LinearLayout android:layout_marginLeft="10dp" android:layout_width="match_parent" android:layout_gravity="center" android:layout_height="wrap_content" android:orientation="vertical"> <TextView android:id="@+id/title" android:text="商品标题" android:layout_width="match_parent" android:layout_height="wrap_content"/> <RelativeLayout android:layout_marginTop="15dp" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/price" android:layout_alignParentLeft="true" android:text="优惠价:¥99.99" android:textColor="@android:color/holo_red_light" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <yangxinlang.bawei.com.moniyuekao.widget.MyJIaJianView android:id="@+id/jiajianqi" android:layout_alignParentRight="true" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </RelativeLayout> </LinearLayout> </LinearLayout> <View android:layout_width="match_parent" android:layout_height="1px" android:background="#999999"/> </LinearLayout>
CartAllCheckboxListener:
public interface CartAllCheckboxListener { void notifyAllCheckboxStatus(); }
CartCheckListener:】
public interface CartCheckListener { void notifyParent(); }
MyJIaJianView 购物车加减器 自定义实现:
import android.content.Context; import android.support.annotation.Nullable; import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.EditText; import android.widget.LinearLayout; import android.widget.TextView; import android.widget.Toast; import yangxinlang.bawei.com.moniyuekao.R; public class MyJIaJianView extends LinearLayout { private TextView jiaTv,jiantv; private EditText numEt; private int num = 1; public MyJIaJianView(Context context) { this(context,null); } public MyJIaJianView(Context context, @Nullable AttributeSet attrs) { this(context, attrs,0); } public MyJIaJianView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); init(context); } /** * 初始化自定义的布局 */ private void init(Context context) { View view = LayoutInflater.from(context).inflate(R.layout.jia_jian_layout,this,true); // addView(view); jiantv = view.findViewById(R.id.jian); jiaTv = view.findViewById(R.id.jia); numEt = view.findViewById(R.id.num); numEt.setText(num+""); jiaTv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { num++; numEt.setText(num+""); if (jiaJianListener!=null){ jiaJianListener.getNum(num); } } }); jiantv.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { num--; if (num<=0){ Toast.makeText(getContext(), "数量不能小于1", Toast.LENGTH_SHORT).show(); num = 1; } numEt.setText(num+""); if (jiaJianListener!=null){ jiaJianListener.getNum(num); } } }); } /** * 设置editext数量 * @param */ public void setNumEt(int n) { numEt.setText(n+""); num = Integer.parseInt(numEt.getText().toString()); } private JiaJianListener jiaJianListener; public void setJiaJianListener(JiaJianListener jiaJianListener) { this.jiaJianListener = jiaJianListener; } public interface JiaJianListener{ void getNum(int num); } }
jia_jian_layout布局实现:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="5dp" android:orientation="horizontal" android:background="@drawable/jia_jian_bg"> <TextView android:id="@+id/jian" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="-" android:textSize="25sp" android:padding="5dp"/> <View android:layout_width="1px" android:layout_height="match_parent" android:background="#999999"/> <EditText android:id="@+id/num" android:layout_weight="1" android:text="10" android:gravity="center" android:background="#00000000" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <View android:layout_width="1px" android:layout_height="match_parent" android:background="#999999"/> <TextView android:id="@+id/jia" android:textSize="25sp" android:padding="5dp" android:text="+" android:layout_width="wrap_content" android:layout_height="wrap_content"/> </LinearLayout>
bean工具类实现:
import java.util.List; public class CartBean { /** * msg : 请求成功 * code : 0 * data : [{"list":[{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","num":20,"pid":57,"price":5199,"pscid":40,"selected":0,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银\r\n"},{"bargainPrice":99,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10Na4ec7f39.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12Ne3e6bc56.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12N5b900606.jpg!q70.jpg","num":3,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"}],"sellerName":"商家1","sellerid":"1"},{"list":[{"bargainPrice":6666,"createtime":"2017-10-10T16:01:31","detailUrl":"https://item.m.jd.com/product/5089273.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8284/363/1326459580/71585/6d3e8013/59b857f2N6ca75622.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9346/182/1406837243/282106/68af5b54/59b8480aNe8af7f5c.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8434/54/1359766007/56140/579509d9/59b85801Nfea207db.jpg!q70.jpg","num":3,"pid":46,"price":234,"pscid":39,"selected":0,"sellerid":2,"subhead":"【iPhone新品上市】新一代iPhone,让智能看起来更不一样","title":"Apple iPhone 8 Plus (A1864) 64GB 金色 移动联通电信4G手机"},{"bargainPrice":11800,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/5025518.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t8830/106/1760940277/195595/5cf9412f/59bf2ef5N5ab7dc16.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5428/70/1520969931/274676/b644dd0d/591128e7Nd2f70da0.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t5566/365/1519564203/36911/620c750c/591128eaN54ac3363.jpg!q70.jpg","num":1,"pid":58,"price":6399,"pscid":40,"selected":0,"sellerid":2,"subhead":"升级4G大显存!Nvme协议Pcie SSD,速度快人一步】GTX1050Ti就选拯救者!专业游戏键盘&新模具全新设计!","title":"联想(Lenovo)拯救者R720 15.6英寸游戏笔记本电脑(i5-7300HQ 8G 1T+128G SSD GTX1050Ti 4G IPS 黑)"}],"sellerName":"商家2","sellerid":"2"},{"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":3455,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","num":1,"pid":48,"price":222,"pscid":39,"selected":0,"sellerid":4,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家4","sellerid":"4"},{"list":[{"bargainPrice":1999,"createtime":"2017-10-10T16:09:02","detailUrl":"https://item.m.jd.com/product/5025971.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t7210/232/3738666823/232298/9004583e/59c3a9a7N8de42e15.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8356/82/2107423621/109733/c019b8c6/59c3a9a6Ne9a4bdd7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t10219/74/25356012/171379/7d55e296/59c3a9a8N82fa6e02.jpg!q70.jpg","num":1,"pid":49,"price":333,"pscid":39,"selected":0,"sellerid":5,"subhead":"vivo X20 带你开启全面屏时代!逆光也清晰,照亮你的美!","title":"vivo X20 全面屏手机 全网通 4GB+64GB 金色 移动联通电信4G手机 双卡双待"}],"sellerName":"商家5","sellerid":"5"},{"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":1,"pid":62,"price":15999,"pscid":40,"selected":0,"sellerid":6,"subhead":"购买电脑办公部分商品满1元返火车票5元优惠券(返完即止)","title":"全球购 新款Apple MacBook Pro 苹果笔记本电脑 银色VP2新13英寸Bar i5/8G/256G"},{"bargainPrice":3455,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","num":1,"pid":50,"price":444,"pscid":39,"selected":0,"sellerid":6,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家6","sellerid":"6"},{"list":[{"bargainPrice":3455,"createtime":"2017-10-03T23:53:28","detailUrl":"https://item.m.jd.com/product/12224420750.html?utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t9106/106/1785172479/537280/253bc0ab/59bf78a7N057e5ff7.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8461/5/1492479653/68388/7255e013/59ba5e84N91091843.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t8803/356/1478945529/489755/2a163ace/59ba5e84N7bb9a666.jpg!q70.jpg","num":2,"pid":52,"price":666,"pscid":39,"selected":0,"sellerid":8,"subhead":"【现货新品抢购】全面屏2.0震撼来袭,骁龙835处理器,四曲面陶瓷机","title":"小米(MI) 小米MIX2 手机 黑色 全网通 (6GB+64GB)【标配版】"}],"sellerName":"商家8","sellerid":"8"},{"list":[{"bargainPrice":2999,"createtime":"2017-10-14T21:48:08","detailUrl":"https://item.m.jd.com/product/2385655.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t2068/298/2448145915/157953/7be197df/56d51a42Nd86f1c8e.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2437/128/1687178395/117431/bcc190c1/56d3fcbaNb2963d21.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t2467/222/2263160610/95597/927b8a2f/56d3eafeNdecebeb6.jpg!q70.jpg","num":2,"pid":53,"price":777,"pscid":39,"selected":0,"sellerid":9,"subhead":"Super AMOLED三星双曲面2K 屏,支持无线充电!","title":"三星 Galaxy S7 edge(G9350)4GB+32GB 铂光金 移动联通电信4G手机 双卡双待"}],"sellerName":"商家9","sellerid":"9"}] */ 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 { private boolean isSelected = false; public boolean isSelected() { return isSelected; } public void setSelected(boolean selected) { isSelected = selected; } /** * list : [{"bargainPrice":11800,"createtime":"2017-10-10T17:33:37","detailUrl":"https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg","num":20,"pid":57,"price":5199,"pscid":40,"selected":0,"sellerid":1,"subhead":"【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统","title":"小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银\r\n"},{"bargainPrice":99,"createtime":"2017-10-14T21:38:26","detailUrl":"https://item.m.jd.com/product/4345173.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends","images":"https://m.360buyimg.com/n0/jfs/t6037/35/2944615848/95178/6cd6cff0/594a3a10Na4ec7f39.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6607/258/1025744923/75738/da120a2d/594a3a12Ne3e6bc56.jpg!q70.jpg|https://m.360buyimg.com/n0/jfs/t6370/292/1057025420/64655/f87644e3/594a3a12N5b900606.jpg!q70.jpg","num":3,"pid":45,"price":2999,"pscid":39,"selected":0,"sellerid":1,"subhead":"高清双摄,就是清晰!2000+1600万高清摄像头,6GB大内存+高通骁龙835处理器,性能怪兽!","title":"一加手机5 (A5000) 6GB+64GB 月岩灰 全网通 双卡双待 移动联通电信4G手机"}] * sellerName : 商家1 * sellerid : 1 */ 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 { private boolean isSelected = false; public boolean isSelected() { return isSelected; } public void setSelected(boolean selected) { isSelected = selected; } private int totalNum = 1;//加减器的数量 public int getTotalNum() { return totalNum; } public void setTotalNum(int totalNum) { this.totalNum = totalNum; } /** * bargainPrice : 11800.0 * createtime : 2017-10-10T17:33:37 * detailUrl : https://item.m.jd.com/product/4338107.html?utm#_source=androidapp&utm#_medium=appshare&utm#_campaign=t#_335139774&utm#_term=QQfriends * images : https://m.360buyimg.com/n0/jfs/t6700/155/2098998076/156185/6cf95035/595dd5a5Nc3a7dab5.jpg!q70.jpg * num : 20 * pid : 57 * price : 5199.0 * pscid : 40 * selected : 0 * sellerid : 1 * subhead : 【i5 MX150 2G显存】全高清窄边框 8G内存 256固态硬盘 支持指纹识别 预装WIN10系统 * title : 小米(MI)Air 13.3英寸全金属轻薄笔记本(i5-7200U 8G 256G PCle SSD MX150 2G独显 FHD 指纹识别 Win10)银 */ 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; 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; }