Android ListView中的EditText 动态更新数据源 SimpleAdapter (二)
2018-03-21 10:02
435 查看
更改数据源后要先使用
adapter.notifyDataSetChanged();刷新数据
public void FlushPrice(){ ListView list= (ListView)findViewById(R.id.act_setorder_foodListView);//获得listview for (int i = 0; i < list.getChildCount(); i++) { LinearLayout layout = (LinearLayout)list.getChildAt(i);// 获得子item的layout TextView textView = (TextView) layout.findViewById(R.id.Text_one_name) ; EditText et = (EditText) layout.findViewById(R.id.editText_one_price);// 从layout中获得控件,根据其id for (GoodsItem goodsItem :goodsItemList) { if (textView.getText().equals(goodsItem.name)) { goodsItem.reall_price = Double.parseDouble(String.valueOf(et.getText())); } } } all_money = 0; for (GoodsItem goodsList : goodsItemList) { all_money+= goodsList.count*goodsList.reall_price; all_price+= goodsList.count*goodsList.price; } price.setText(String.valueOf(all_money)); personalList.clear(); personalList1.clear(); for (GoodsItem goodsList : goodsItemList) { Map<String,Object> map=new HashMap<String,Object>(); map.put("name",goodsList.name); map.put("number",goodsList.count+goodsList.product_units); map.put("one_price",goodsList.reall_price); personalList1.add(map); } personalList.addAll(personalList1); adapter.notifyDataSetChanged(); }这样就可以实现动态更新数据源了,因为每一个item有区分,所有超出屏幕范围外的item也可以更新数据了
相关文章推荐
- Android ListView中的EditText 动态更新数据源 SimpleAdapter (一)
- 在edittext中输入内容,动态匹配更新 listview的数据(EditText中边输入,listView边更新)
- EditText动态管理密码显示与隐藏,明文与星号
- 润乾报表:动态改变填报更新数据的数据源
- 通过环境变量设置WEB项目数据源(Spring)及其项目配置文件路径,动态更新数据源及项目配置
- Android EditText的输入监听,输入字符的动态获取
- EditText 输入时动态显示结果
- android ListView中自定义SimpleAdapter动态添加ratingBar及图片更新
- EditText动态设置输入类型与过滤器的使用
- EditText+ListView实现从动态显示数据库数据
- EditText动态输入监听
- android之EditText实现动态显示隐藏密码输入框的内容(实用)
- EditText动态添加图片-----SpannableString来设置超链接、颜色、字体、图片属性
- Android控件 动态初始化 动态加载 EditText显示光标 隐藏键盘
- [置顶] Android仿微信搜索,Recyclerview+关键字动态匹配筛选变色效果(Edittext+Recyclerview)
- android开发中 如何动态更新TextView的内容?
- EditText + ListView 之间的搜索配置 动态加载ListView数据
- 根据Edittext搜索,listview动态显示
- listView中嵌套EditText,动态获取EditText中的值
- Android软键盘(输入法)使用大杂烩:避免进入页面EditText自动弹出软键盘-2013.11.08更新