购物商品:
bean类:
public class GouWuDataBean implements Serializable {
private int commodityId;
private String commodityName;
private int count;
private String pic;
private double price;
private boolean isChecked;
public int getCommodityId() {
return commodityId;
}
public void setCommodityId(int commodityId) {
this.commodityId = commodityId;
}
public String getCommodityName() {
return commodityName;
}
public void setCommodityName(String commodityName) {
this.commodityName = commodityName;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
public String getPic() {
return pic;
}
public void setPic(String pic) {
this.pic = pic;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public boolean isChecked() {
return isChecked;
}
public void setChecked(boolean checked) {
isChecked = checked;
}
}
public class GouWuListBean implements Serializable {
private String categoryName;
private List<GouWuDataBean> shoppingCartList;
public String getCategoryName() {
return categoryName;
}
public void setCategoryName(String categoryName) {
this.categoryName = categoryName;
}
public List<GouWuDataBean> getShoppingCartList() {
return shoppingCartList;
}
public void setShoppingCartList(List<GouWuDataBean> shoppingCartList) {
this.shoppingCartList = shoppingCartList;
}
}
public class GouWuResult implements Serializable {
private List<GouWuListBean> result;
private String message;
private String status;
public List<GouWuListBean> getResult() {
return result;
}
public void setResult(List<GouWuListBean> result) {
this.result = result;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
}
public class GouWuAdapter extends RecyclerView.Adapter<GouWuAdapter.ViewHolder> {
public List<GouWuListBean> list=new ArrayList<>();
public Context context;
public boolean isChecked;
public List<GouWuListBean> getList() {
return list;
}
public void setChecked(boolean checked) {
isChecked = checked;
for (int i = 0; i < list.size(); i++) {
GouWuListBean gouWuListBean = list.get(i);
List<GouWuDataBean> shoppingCartList = gouWuListBean.getShoppingCartList();
for (int j = 0; j < shoppingCartList.size(); j++) {
GouWuDataBean gouWuDataBean = shoppingCartList.get(j);
gouWuDataBean.setChecked(isChecked);
}
}
notifyDataSetChanged();
}
public GouWuAdapter(List<GouWuListBean> list, Context context) {
this.list.addAll(list);
this.context = context;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View inflate = LayoutInflater.from(context).inflate(R.layout.gouwu_name, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(inflate);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
GouWuListBean gouWuListBean = list.get(i);
viewHolder.gouwu_gouwuName.setText(gouWuListBean.getCategoryName());
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(context);
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
viewHolder.gouwu_recycles.setLayoutManager(linearLayoutManager);
GouWuListBean gouWuListBean1 = list.get(i);
List<GouWuDataBean> shoppingCartList = gouWuListBean1.getShoppingCartList();
GouWuFenAdapter gouWuFen_adapter = new GouWuFenAdapter(shoppingCartList, context);
viewHolder.gouwu_recycles.setAdapter(gouWuFen_adapter);
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
private TextView gouwu_gouwuName;
public RecyclerView gouwu_recycles;
public ViewHolder(@NonNull View itemView) {
super(itemView);
gouwu_gouwuName = (TextView)itemView.findViewById(R.id.gouwu_gouwuName);
gouwu_recycles = (RecyclerView)itemView.findViewById(R.id.gouwu_recycles);
}
}
}
public class GouWuFenAdapter extends RecyclerView.Adapter<GouWuFenAdapter.ViewHolder> {
public List<GouWuDataBean> list = new ArrayList<>();
public Context context;
public GouWuFenAdapter(List<GouWuDataBean> list, Context context) {
this.list.addAll(list);
this.context = context;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View inflate = LayoutInflater.from(context).inflate(R.layout.gouwu_item, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(inflate);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull final ViewHolder viewHolder, int i) {
final GouWuDataBean gouWuDataBean = list.get(i);
viewHolder.gouwu_item_name.setText(gouWuDataBean.getCommodityName());
Glide.with(context).load(gouWuDataBean.getPic()).into(viewHolder.gouwu_item_imgs);
viewHolder.gouwu_item_price.setText(gouWuDataBean.getPrice()+"");
boolean checked = gouWuDataBean.isChecked();
viewHolder.gouwu_item_chenckbox.setChecked(checked);
int count = gouWuDataBean.getCount();
viewHolder.addView.setNum(count);
viewHolder.addView.setDataCallBack(new Asease.DataCallBack() {
@Override
public void back(int numa) {
gouWuDataBean.setCount(numa);
EventBus.getDefault().post(new EventBean());
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public Asease addView;
public CheckBox gouwu_item_chenckbox;
public ImageView gouwu_item_imgs;
public TextView gouwu_item_name;
public TextView gouwu_item_price;
public ViewHolder(@NonNull View itemView) {
super(itemView);
addView = (Asease) itemView.findViewById(R.id.addView);
gouwu_item_imgs = (ImageView) itemView.findViewById(R.id.gouwu_item_imgs);
gouwu_item_name = (TextView) itemView.findViewById(R.id.gouwu_item_name);
gouwu_item_price = (TextView) itemView.findViewById(R.id.gouwu_item_price);
gouwu_item_chenckbox = (CheckBox) itemView.findViewById(R.id.gouwu_item_chenckbox);
}
}
}
public class Fragment_GouWu extends BaseFragment<GouWuPresentImpl> implements GouWuContract.IView {
private RecyclerView gouwu_recycles;
private CheckBox gouwu_zong_chengckbox;
private TextView heji_price;
private TextView tijiao_nums;
private GouWuAdapter gouWuAdapter;
@Override
protected int initLayout() {
return R.layout.layout_gouwu;
}
@Override
protected void initView(View view) {
EventBus.getDefault().register(this);
gouwu_recycles = (RecyclerView) view.findViewById(R.id.gouwu_recycles);
gouwu_zong_chengckbox = (CheckBox) view.findViewById(R.id.gouwu_zong_chengckbox);
heji_price = (TextView) view.findViewById(R.id.heji_price);
tijiao_nums = (TextView) view.findViewById(R.id.tijiao_nums);
}
@Override
protected GouWuPresentImpl initPresent() {
return new GouWuPresentImpl();
}
@Override
protected void initData() {
presents.GouWushow();
gouwu_zong_chengckbox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean checked = gouwu_zong_chengckbox.isChecked();
gouWuAdapter.setChecked(checked);
toPrice();
}
});
}
@Subscribe
public void JieShou(EventBean eventBean){
toPrice();
}
private void toPrice() {
double tob=0;
List<GouWuListBean> list = gouWuAdapter.getList();
for (int i=0;i<list.size();i++){
GouWuListBean gouWuListBean = list.get(i);
List<GouWuDataBean> shoppingCartList = gouWuListBean.getShoppingCartList();
for (int j=0;j<shoppingCartList.size();j++){
GouWuDataBean gouWuDataBean = shoppingCartList.get(j);
if (gouWuDataBean.isChecked()) {
int count = gouWuDataBean.getCount();
double price = gouWuDataBean.getPrice();
double temp = count * price;
tob += temp;
}
}
}
heji_price.setText(tob+"");
}
@Override
public void success(GouWuResult gouWuResult) {
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
gouwu_recycles.setLayoutManager(linearLayoutManager);
List<GouWuListBean> result = gouWuResult.getResult();
gouWuAdapter = new GouWuAdapter(result, getContext());
gouwu_recycles.setAdapter(gouWuAdapter);
}
@Override
public void error(String msg) {
}
}
契约类:
public interface GouWuContract {
interface IView extends BaseView{
void success(GouWuResult gouWuResult);
void error(String msg);
}
interface IModel{
void GouWushow(DataCallBack dataCallBack);
interface DataCallBack{
void success(GouWuResult gouWuResult);
void error(String msg);
}
}
interface GouWuPresent{
void GouWushow();
}
}
P层:
public class GouWuPresentImpl extends BasePresent<GouWuContract.IView> implements GouWuContract.GouWuPresent {
private GouWuModeImpl gouWuMode;
@Override
protected void initModel() {
gouWuMode = new GouWuModeImpl();
}
@Override
public void GouWushow() {
gouWuMode.GouWushow(new GouWuContract.IModel.DataCallBack() {
@Override
public void success(GouWuResult gouWuResult) {
getView().success(gouWuResult);
}
@Override
public void error(String msg) {
getView().error(msg);
}
});
}
}
接口类
public interface ApiService {
@GET("order/verify/v1/findShoppingCart")
@Headers({"userId:10922","sessionId:157701664069710922"})
Observable<GouWuResult> getGouWu();
@GET("commodity/v1/findCategory")
Observable<LeftResultBean> show();
@GET("commodity/v1/findCommodityByCategory")
Observable<RightResultBean> RightShow(@QueryMap Map<String,String> map);
}
自定义加减器:
public class Asease extends LinearLayout {
private TextView aseas_add;
private TextView aseas_jain;
private TextView aseas_num;
public DataCallBack dataCallBack;
public Asease(Context context) {
super(context);
initContext(context);
}
public Asease(Context context, AttributeSet attrs) {
super(context, attrs);
initContext(context);
}
public Asease(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initContext(context);
}
private void initContext(Context context) {
View inflate = LayoutInflater.from(context).inflate(R.layout.asease, this, true);
aseas_add = (TextView)inflate.findViewById(R.id.aseas_add);
aseas_jain = (TextView)inflate.findViewById(R.id.aseas_jian);
aseas_num = (TextView)inflate.findViewById(R.id.aseas_num);
initData();
}
private void initData() {
aseas_add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String s = aseas_num.getText().toString();
Integer nums = Integer.valueOf(s);
nums++;
aseas_num.setText(nums+"");
dataCallBack.back(nums);
}
});
aseas_jain.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String ss = aseas_jain.getText().toString();
Integer nums = Integer.valueOf(ss);
nums--;
if (nums<0){
nums=0;
Toast.makeText(getContext(),"最小值",Toast.LENGTH_SHORT).show();
}
aseas_num.setText(nums+"");
dataCallBack.back(nums);
}
});
}
public void setDataCallBack(DataCallBack dataCallBack){
this.dataCallBack = dataCallBack;
}
public interface DataCallBack{
void back(int numa);
}
public void setNum(int nums) {
aseas_num.setText(nums+"");
}
}
抽基类:
public abstract class BaseFragment<P extends BasePresent> extends Fragment implements BaseView{
public P presents;
public BaseFragment(){
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
return inflater.inflate(initLayout(),container,false);
}
protected abstract int initLayout();
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
initView(view);
}
protected abstract void initView(View view);
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
presents = initPresent();
if (presents!=null){
presents.attach(this);
}
initData();
}
protected abstract P initPresent();
protected abstract void initData();
@Override
public void onDestroy() {
super.onDestroy();
presents.detach();
}
}
basepresent:
public abstract class BasePresent<V extends BaseView> {
private WeakReference<V> weakReference;
public BasePresent(){
initModel();
}
protected abstract void initModel();
public void attach(V v){
weakReference = new WeakReference<>(v);
}
public void detach(){
if (weakReference != null){
weakReference.clear();
weakReference = null;
}
}
public V getView(){
V v1 = weakReference.get();
return v1;
}
}
分类:
左边适配器:
public class LeftAdapter extends RecyclerView.Adapter<LeftAdapter.ViewHolder> {
public List<LeftDataBean> list=new ArrayList<>();
public Context context;
public LeftAdapter(List<LeftDataBean> list, Context context) {
this.list.addAll(list);
this.context = context;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View inflate = LayoutInflater.from(context).inflate(R.layout.left_adapter, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(inflate);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
final LeftDataBean leftDataBean = list.get(i);
viewHolder.leftadapter_tx_.setText(leftDataBean.getName());
viewHolder.leftadapter_tx_.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
EventBus.getDefault().postSticky(leftDataBean);
}
});
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
public TextView leftadapter_tx_;
public ViewHolder(@NonNull View itemView) {
super(itemView);
leftadapter_tx_ = (TextView)itemView.findViewById(R.id.leftadapter_tx_);
}
}
}
右边适配器:
public class RightAdapter extends RecyclerView.Adapter<RightAdapter.ViewHolder> {
public List<RightDataBean> list=new ArrayList<>();
public Context context;
public void setClear(){
list.clear();
}
public RightAdapter(List<RightDataBean> list, Context context) {
this.list.addAll(list);
this.context = context;
}
public void clear(){
list.clear();
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View inflate = LayoutInflater.from(context).inflate(R.layout.item_right, viewGroup, false);
ViewHolder viewHolder = new ViewHolder(inflate);
return viewHolder;
}
@Override
public void onBindViewHolder(@NonNull ViewHolder viewHolder, int i) {
RightDataBean rightDataBean = list.get(i);
String name = rightDataBean.getCommodityName();
viewHolder.itemRight_name.setText(name);
int price = rightDataBean.getPrice();
viewHolder.itemRight_price.setText(price+"");
String imgs = rightDataBean.getMasterPic();
Glide.with(context).load(imgs).into(viewHolder.itemRight_img);
}
@Override
public int getItemCount() {
return list.size();
}
public class ViewHolder extends RecyclerView.ViewHolder{
public ImageView itemRight_img;
public TextView itemRight_name;
public TextView itemRight_price;
public ViewHolder(@NonNull View itemView) {
super(itemView);
itemRight_img = (ImageView) itemView.findViewById(R.id.itemRight_img);
itemRight_name = (TextView) itemView.findViewById(R.id.itemRight_name);
itemRight_price = (TextView) itemView.findViewById(R.id.itemRight_price);
}
}
}
左边bean类:
public class LeftResultBean implements Serializable {
private String message;
private String status;
private List<LeftListBean> result;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<LeftListBean> getResult() {
return result;
}
public void setResult(List<LeftListBean> result) {
this.result = result;
}
}
public class LeftListBean {
private String id;
private String name;
private List<LeftDataBean> secondCategoryVo;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<LeftDataBean> getSecondCategoryVo() {
return secondCategoryVo;
}
public void setSecondCategoryVo(List<LeftDataBean> secondCategoryVo) {
this.secondCategoryVo = secondCategoryVo;
}
}
public class LeftDataBean implements Serializable {
private String id;
private String name;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
右边bean类:
public class RightResultBean implements Serializable {
private String message;
private String status;
private List<RightDataBean> result;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public List<RightDataBean> getResult() {
return result;
}
public void setResult(List<RightDataBean> result) {
this.result = result;
}
}
public class RightDataBean implements Serializable {
private int commodityId;
private String commodityName;
private String masterPic;
private int price;
private double saleNum;
public int getCommodityId() {
return commodityId;
}
public void setCommodityId(int commodityId) {
this.commodityId = commodityId;
}
public String getCommodityName() {
return commodityName;
}
public void setCommodityName(String commodityName) {
this.commodityName = commodityName;
}
public String getMasterPic() {
return masterPic;
}
public void setMasterPic(String masterPic) {
this.masterPic = masterPic;
}
public int getPrice() {
return price;
}
public void setPrice(int price) {
this.price = price;
}
public double getSaleNum() {
return saleNum;
}
public void setSaleNum(double saleNum) {
this.saleNum = saleNum;
}
}
分类franment:
public class Fragment_FenLie extends BaseFragment<LeftPresentImpl> implements LeftContract.LeftView,RightContract.RightView {
private RecyclerView left_recycles;
private RecyclerView right_recycles;
private RightPresentImpl rightPresent;
HashMap<String, String> map = new HashMap<>();
private RightAdapter rightAdapter;
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.layout_fenlei, container, false);
return view;
}
@Override
protected int initLayout() {
return R.layout.layout_fenlei;
}
@Override
protected void initView(View view) {
left_recycles = (RecyclerView) view.findViewById(R.id.left_recycles);
right_recycles = (RecyclerView) view.findViewById(R.id.right_recycles);
}
@Override
protected LeftPresentImpl initPresent() {
return new LeftPresentImpl();
}
@Override
protected void initData() {
presents.show();
EventBus.getDefault().register(this);
rightPresent = new RightPresentImpl();
rightPresent.attach(this);
map.put("page","1");
map.put("count","5");
map.put("categoryId","1001004002");
rightPresent.RightShow(map);
}
public void initStart() {
map.put("page", "1");
map.put("count", "5");
map.put("categoryId", categoryId);
rightPresent.RightShow(map);
}
private String categoryId;
@Subscribe
public void JieQu(LeftDataBean leftDataBean){
rightAdapter.clear();
categoryId = leftDataBean.getId();
initStart();
}
@Override
public void success(LeftResultBean leftResultBean) {
List<LeftListBean> result = leftResultBean.getResult();
LeftListBean leftListBean = result.get(0);
List<LeftDataBean> secondCategoryVo = leftListBean.getSecondCategoryVo();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
left_recycles.setLayoutManager(linearLayoutManager);
LeftAdapter leftAdapter = new LeftAdapter(secondCategoryVo, getContext());
left_recycles.setAdapter(leftAdapter);
}
@Override
public void error(String msg) {
}
@Override
public void success(RightResultBean rightResultBean) {
List<RightDataBean> result = rightResultBean.getResult();
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
right_recycles.setLayoutManager(linearLayoutManager);
rightAdapter = new RightAdapter(result, getContext());
right_recycles.setAdapter(rightAdapter);
rightAdapter.notifyDataSetChanged();
}
}
左边契约类:
public interface LeftContract {
interface LeftView extends BaseView{
void success(LeftResultBean leftResultBean);
void error(String msg);
}
interface LeftModel{
void show(DataCallBack dataCallBack);
interface DataCallBack{
void success(LeftResultBean leftResultBean);
void error(String msg);
}
}
interface LeftPresent{
void show();
}
}
右边契约类:
public interface RightContract {
interface RightView extends BaseView{
void success(RightResultBean rightResultBean);
void error(String msg);
}
interface RightModel{
void RightShow(Map<String,String> map,DataCallBack dataCallBack);
interface DataCallBack{
void success(RightResultBean rightResultBean);
void error(String msg);
}
}
interface RightPresent{
void RightShow(Map<String,String> map);
}
}
布局:
加减器布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/aseas_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
/>
<TextView
android:id="@+id/aseas_num"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="num"
/>
<TextView
android:id="@+id/aseas_jian"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
/>
</LinearLayout>
</LinearLayout>
gouwu_item:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/gouwu_item_chenckbox"
android:layout_marginTop="30dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/gouwu_item_imgs"
android:src="@mipmap/ic_launcher"
android:layout_width="75dp"
android:layout_height="75dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent">
<TextView
android:id="@+id/gouwu_item_name"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1111111111"
/>
<TextView
android:id="@+id/gouwu_item_price"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1111111111"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<com.bawei.qzz20191221.Asease
android:id="@+id/addView"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.bawei.qzz20191221.Asease>
</LinearLayout>
</LinearLayout>
</LinearLayout>
gouwu_name:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:id="@+id/gouwu_gouwuName"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="名字"
/>
<android.support.v7.widget.RecyclerView
android:id="@+id/gouwu_recycles"
android:layout_width="match_parent"
android:layout_height="wrap_content"></android.support.v7.widget.RecyclerView>
</LinearLayout>
购物总的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent">
<com.jcodecraeer.xrecyclerview.XRecyclerView
android:id="@+id/gouwu_recycles"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
></com.jcodecraeer.xrecyclerview.XRecyclerView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/gouwu_zong_chengckbox"
/>
<TextView
android:text="合计"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/heji_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1111"
/>
<TextView
android:id="@+id/tijiao_nums"
android:layout_marginLeft="170dp"
android:text="点击"
android:layout_width="50dp"
android:layout_height="30dp" />
</LinearLayout>
</LinearLayout>
分类布局:
分类总的布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/left_recycles"
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
<android.support.v7.widget.RecyclerView
android:id="@+id/right_recycles"
android:layout_width="0dp"
android:layout_weight="8"
android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>
</LinearLayout>
左边left_adapter:
<?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">
<TextView
android:layout_marginTop="10dp"
android:id="@+id/leftadapter_tx_"
android:text="1111111"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TextView>
</LinearLayout>
右边item——right:
<?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">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/itemRight_img"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:src="@mipmap/ic_launcher"
android:layout_width="75dp"
android:layout_height="75dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/itemRight_name"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="111111111"
/>
<TextView
android:id="@+id/itemRight_price"
android:layout_marginTop="30dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="111111111"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>