文章标题
来源:互联网 发布:福岛核事故知乎 编辑:程序博客网 时间:2024/06/12 18:48
ListView更新某个item
1、listview包含EditText控件:
private class ViewHolders {
private EditText et_Content;
}
final ViewHolders holders = new ViewHolders();
holders.et_Content = (CLEditText) convertView
.findViewById(R.id.et_process_22);
2、设置EditText值,在activity中获取
holders.et_Content.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // TODO Auto-generated method stub int position1 = (Integer) holders.et_Content.getTag(); ProcessInfo info = mListData.get(position1); info.setContent((holders.et_Content.getText().toString().trim()));String bigStr = holders.et_Content.getText().toString().trim(); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // TODO Auto-generated method stub } @Override public void afterTextChanged(Editable s) { for (int i = 0; i < mListData.size(); i++) { //这里判断要改变的item if (mListData.get(i).getTitle().indexOf("标题") != -1) { try { mListData.get(i) .setContent( CommonTools.digitUppercase(s .toString())); updateSingle(i); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }else{ mListData.get(i) .setContent( mListData.get(i).getContent()); } } }
3.更改item的值
/** * 第一种方法 更新对应view的内容 * * @param position * 要更新的位置 */ private void updateSingle(int position) { View childAt = mList.getChildAt(position - mList.getFirstVisiblePosition() + 1); if (childAt != null) { CLEditText myTv = (CLEditText) childAt.findViewById(R.id.et_process_22); if (myTv != null) {// 当item可见的时候更新 myTv.setText(mListData.get(position).getContent()); } } }
阅读全文
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 判断一颗二叉树是是否是另一颗树的子树
- 贪心算法例题:2079悼念512汶川大地震遇难同胞
- Error:Execution failed for task ':processDebugResources'. > java.lang.IllegalArgumentException (no e
- appium简明教程(1)——appium和它的哲学世界
- linux下gtest&gmock下载
- 文章标题
- 杭电acm 2017字符串统计(字符串处理)
- 对array数组 在[start,end)的元素进行排序 (归并排序)
- 【js基础】js中_proto_ prototype constructor之间的关系
- idea中创建mavenweb项目
- 30分钟掌握ES6/ES2015核心内容(上)
- 【python学习笔记】23:numpy的add和multiply
- Bentley.PULS.XM.V8.9.0.28 数字管道脉动分析
- appium简明教程(2)——appium的基本概念