二级列表购物车
来源:互联网 发布:广电网络设备有哪些 编辑:程序博客网 时间:2024/04/29 06:06
一导依赖mycartutils(购物车) okhttputils(网络请求)
二将mycartutils下的版本改为minSdkVersion 15
主布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.bwei.shoppingdemozong.MainActivity"> <ExpandableListView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/ex" android:layout_weight="1" ></ExpandableListView> <LinearLayout android:layout_width="match_parent" android:layout_height="50dp" android:layout_alignParentBottom="true" android:orientation="horizontal"> <CheckBox android:id="@+id/all" android:layout_width="50dp" android:layout_height="50dp" /> <TextView android:id="@+id/count" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="数量" /> <TextView android:id="@+id/name" android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="价钱" /> </LinearLayout></LinearLayout>
主类
public class MainActivity extends AppCompatActivity { private ExpandableListView ex; private TextView price; private TextView count; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ex = (ExpandableListView) findViewById(R.id.ex); final CheckBox all = (CheckBox) findViewById(R.id.all); count = (TextView) findViewById(R.id.count); price = (TextView) findViewById(R.id.name); HttpUtils.doGet("http://www.yulin520.com/a2a/impressApi/news/mergeList?sign=C7548DE604BCB8A17592EFB9006F9265&pageSize=20&gender=2&ts=1871746850&page=1 ", new HttpUtils.GsonObjectCallback<JavaBean>() { @Override public void onUi(JavaBean javaBean) { List<JavaBean.DataBean> data = javaBean.getData(); List<GroupBean> groupBeen = new ArrayList<GroupBean>(); List<List<ChildBean>> child = new ArrayList<List<ChildBean>>(); for (int i = 0; i < data.size(); i++) { groupBeen.add(new GroupBean(data.get(i).getTitle(), false)); } for (int i = 0; i < data.size(); i++) { List<ChildBean> ch = new ArrayList<ChildBean>(); for (int j = 0; j < data.size(); j++) { ch.add(new ChildBean(data.get(j).getTitle(), "100", data.get(j).getImg(), false, 1)); } child.add(ch); }//依赖中的方法 CartUtils.setCartData(MainActivity.this, groupBeen, child, ex, all, price, count); } @Override public void onFailed(Call call, IOException e) { } }); }}
四将okhttputils下的三个类复制到工程里
调方法
阅读全文
0 0
- 二级列表购物车
- 购物车二级列表
- 购物车(二级列表)
- 二级列表购物车
- 购物车二级列表
- 购物车二级列表
- 二级列表购物车
- 二级列表购物车
- 购物车二级列表
- 二级列表购物车
- 二级列表购物车
- 二级列表 购物车
- 购物车二级列表
- 二级列表购物车++
- 购物车二级列表
- 二级列表购物车
- 二级列表仿购物车
- Android 二级列表购物车
- 2017年泰国国际珠宝首饰展会刊(参展商名录)
- [设计模式]面向对象设计原则之迪米特法则(最少知道法则)
- 简单好用日志工具
- eclipse:自动调整代码格式
- 趣店能否撑起百亿美元市值!
- 二级列表购物车
- jemeter之性能测试
- 【ES6】const命令和import命令
- SUM OVER PARTITION BY ORDER BY(分组累计计算方法)
- IO流
- thymeleaf项目路径
- LeetCode 24. Swap Nodes in Pairs
- //BottomTabBar实现底部选项卡
- 原生选择第一个元素