购物车的布局和实现 《一》

//activity_main的布局

<RelativeLayout
    android:id="@+id/bottom_layout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true">

    <CheckBox
        android:id="@+id/Check_All"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="全选" />
    <TextView
        android:id="@+id/All_Price"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:text="价格"/>
    <TextView
        android:id="@+id/Go_To_JS"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:text="去结算(0)" />
</RelativeLayout>

<ExpandableListView
    android:id="@+id/Expand_View"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/bottom_layout" />

// MainActivity的页面
public class MainActivity extends AppCompatActivity implements IView {
private CheckBox Check_All;
private TextView All_Price;
private TextView Go_To_JS;
private RelativeLayout bottom_layout;
private ExpandableListView Expand_View;
private String mUrl=“http://www.wanandroid.com/tools/mockapi/6523/restaurant-list”;
ArrayList<User.DataBean> mList=new ArrayList<>();
private PerenerImpl perener;
private MyAdapter adapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    initView();
    perener = new PerenerImpl(this);
    perener.startRequest(mUrl);
    adapter = new MyAdapter(mList,this);
    Expand_View.setAdapter(adapter);
}


@Override
public void setData(User data) {
    mList.addAll(data.getData());
    adapter.notifyDataSetChanged();
}

@Override
public void setError(String error) {

}

private void initView() {
    Check_All = (CheckBox) findViewById(R.id.Check_All);
    All_Price = (TextView) findViewById(R.id.All_Price);
    Go_To_JS = (TextView) findViewById(R.id.Go_To_JS);
    bottom_layout = (RelativeLayout) findViewById(R.id.bottom_layout);
    Expand_View = (ExpandableListView) findViewById(R.id.Expand_View);
}

}

//二级列表子类的布局:chencbox 图片和商品介绍

<CheckBox
    android:id="@+id/Child_Check_CB"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

<ImageView
    android:id="@+id/Child_Icon"
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:layout_marginLeft="20dp"
    android:scaleType="centerCrop"
    android:src="@color/colorPrimary" />

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

    <TextView
        android:id="@+id/Child_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="2"
        android:text="商品标题" />

    <TextView
        android:id="@+id/Child_price"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        android:text="¥0.0" />

</LinearLayout>

//二级列表的父列表的布局:checkbox和textview





//加减的布局

<TextView
    android:id="@+id/delete_tv"
    android:layout_width="10dp"
    android:layout_height="match_parent"
    android:background="#ffffff"
    android:gravity="center"
    android:text="-"
    android:textSize="16sp" />

<TextView
    android:id="@+id/product_number_tv"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_marginLeft="2dp"
    android:layout_weight="1"
    android:background="#ffffff"
    android:gravity="center"
    android:text="1" />

<TextView
    android:id="@+id/add_tv"
    android:layout_width="10dp"
    android:layout_height="match_parent"
    android:layout_marginLeft="2dp"
    android:background="#ffffff"
    android:gravity="center"
    android:text="+"
    android:textSize="16sp" />
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值