• android购物车遇到的问题


    近期 做购物车的时候 ,遇到几个问题。如今 总结例如以下:

    1:不让listview复用组件(购物车。或者有特殊操作的时候):

    自己保存全部的view对象

     public View getView(final int position, View convertView, ViewGroup parent) {
    
            final DaydayCouponBean bean = list.get(position);
            View view =  DataCenter.shoppingCarMap.get(new Integer(position));
                convertView = LayoutInflater.from(context).inflate(R.layout.daydaycoupon_shoppingcar_item, null);
                DataCenter.shoppingCarMap.put(position, convertView);
            } else {
                convertView = DataCenter.shoppingCarMap.get(new Integer(position));
            }
    
            return view;
        }

    相应的Map

     <strong>public static TreeMap<Integer, View> shoppingCarMap = new TreeMap<Integer, View>();</strong>

    2:scrowvdiw嵌套lsitview 高度无法计算 每次更新数据集Arraylist之后,手动计算lsitview的高度,全部的item就都会初始化

    或者 购物车 要 一次性 初始化全部的 item(如 获取全部的商品总额,不是当前页吗可见区域的总额

    <span style="font-size:14px;">    adapter.notifyDataSetChanged();
         float density = getResources().getDisplayMetrics().density; // 屏幕密度(0.75 / 1.0 / 1.5)
       <strong>  UIUitls.setListViewHeightBasedOnChildren(listView, (int) (density * 20));</strong></span>

    3:listview嵌套问题具体见:

    http://ryanjoy.iteye.com/blog/1291331

    注意,在使用listview嵌套listview发现,计算的高度还是比較诡异,解决的方法??要使用自己定义的listview

    /**
     * Created by david on 2014/6/30.
     * 解决lsitview 嵌套 listveiw 高度计算错误。使用的lsitview
     */
    public class MyListview extends ListView {
    
        public MyListview(Context context) {
            super(context);
        }
    
        public MyListview(Context context, AttributeSet attrs) {
            super(context, attrs);
        }
    
        public MyListview(Context context, AttributeSet attrs, int defStyle) {
            super(context, attrs, defStyle);
        }
    
        @Override
        protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
           <strong> int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
                    MeasureSpec.AT_MOST);</strong>
            super.onMeasure(widthMeasureSpec, expandSpec);
        }
    }
    每次又一次刷新lsitrview的时候

      UIUitls.setListViewHeightBasedOnChildren(listView, DensityUtil.dip2px(120),beans.size() );
      adapter.notifyDataSetChanged();

    android UI进阶之实现listview中checkbox的多选与记录

  • 相关阅读:
    开启sentry权限控制hue
    hive_server2的权限控制
    自带的simple认证
    tableau备份
    tableau分布式添加节点
    升级tableau版本
    tableau日常管理
    mavn Nexus Repository Manager漏洞
    第3章:打造命令行工具
    基于从库+binlog方式恢复数据
  • 原文地址:https://www.cnblogs.com/yangykaifa/p/6726804.html
Copyright © 2020-2023  润新知