Android仿京东购物车效果
来源:互联网 发布:photoshop8.0软件下载 编辑:程序博客网 时间:2024/05/22 07:08
模仿京东购物车做了个简单的购物车效果。 先上图:
最近要做个电商项目。 本来想去网上找个代码copy的。 找了半天没找到。 无奈只能自己写一个了。 说下整个思路,两个Listview,item的加减用回调或者观察者模式(哈哈,新学的).。 看自己怎么习惯吧 。 说下碰到的问题 。两个Listview 做完后发现第二个Listview只能显示一条数据,调试后发现值穿过来了。还是只能显示第一条。各种Width,Height赋值,还是没用 好吧。 经过查阅资料才想起来,我以前碰到过这问题。 ListView中嵌套ListView,无法正确的计算ListView的大小 于是重写了ListView方法,重新计算子Listview中的高度。
public class MyListView extends ListView { public MyListView(Context paramContext) { super(paramContext); } public MyListView(Context paramContext, AttributeSet paramAttributeSet) { super(paramContext, paramAttributeSet); } public MyListView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { super(paramContext, paramAttributeSet, paramInt); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec); }}
第一个Listview item中的代码贴出来,给大家看下。。 其他代码就不贴了,因为比较简单。
<?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="match_parent" android:orientation="vertical" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginLeft="5dp" android:background="#F8F8F8" android:orientation="horizontal" > <ImageView android:id="@+id/check" android:layout_width="25dp" android:layout_height="25dp" android:layout_gravity="center" android:src="@drawable/nocheck" /> <ImageView android:id="@+id/shopimg" android:layout_width="25dp" android:layout_height="40dp" android:layout_marginLeft="20dp" android:src="@drawable/jd" /> <TextView android:id="@+id/shopname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="2dp" android:text="京东自营" android:textSize="19sp" /> </LinearLayout> <com.tdc.shop.ui.MyListView android:id="@+id/shopview" android:layout_width="match_parent" android:layout_height="wrap_content" /></LinearLayout>
0 0
- Android仿京东购物车效果
- Android 购物车效果
- Android实现购物车效果
- Android 实现购物车动画效果
- Android 仿京东购物车
- 购物车飞入效果
- 购物车效果实现
- Android 实现蘑菇街购物车动画效果
- android实现蘑菇街购物车动画效果
- Android 实现蘑菇街购物车动画效果
- Android天猫购物车EditText编辑商品数量效果
- Android 实现蘑菇街购物车动画效果
- Android 实现蘑菇街购物车动画效果
- Android 实现蘑菇街购物车动画效果
- Android 实现蘑菇街购物车动画效果
- Android将商品加入购物车的动画效果
- Android仿淘宝加入购物车布局效果
- android可拖动的购物车效果(含点击放入购物车动画代码)
- 服务器使用df和du查看磁盘大小不一致
- IAT
- openwrt 编译软件包
- Max Sum
- Python学习之Morvan 01——tkinter学习01
- Android仿京东购物车效果
- Android 中的代码混淆
- 解决正则问题 1
- AlertDialog.Builder弹窗强制选择效果
- 进制转换
- 如何编写API文档?高校开发
- Azure Redis Cache 简介
- oc语言的时间输出格式
- Qt中打开二维、三维的工程图