从自定义列表视图中删除项目

编程入门 行业动态 更新时间:2024-10-19 16:29:58
本文介绍了从自定义列表视图中删除项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图删除按钮,点击自定义列表视图的项目,删除功能工作正常,但prblem是当我点击按钮后,项目DONOT删除当场,当我重新加载

i'm trying to delete custom listview's item on button click , delete function is working correctly, but prblem is when i click on button then item donot delete on the spot, when i reload

@Override public View getView(final int paramInt, View paramView, ViewGroup paramViewGroup) { // TODO Auto-generated method stub LayoutInflater inflator = activity.getLayoutInflater(); if (paramView == null) { view = new ViewHolder(); paramView = inflator.inflate(R.layout.listview_row, null); view.header = (TextView) paramView.findViewById(R.id.tvHeader); view.from = (TextView) paramView.findViewById(R.id.tvfrom); view.to = (TextView) paramView.findViewById(R.id.tvto); view.value = (EditText) paramView.findViewById(R.id.etValue); view.imgViewFlag = (ImageView) paramView.findViewById(R.id.ibclose); view.result = (TextView) paramView.findViewById(R.id.tvResult); paramView.setTag(view); } else { view = (ViewHolder) paramView.getTag(); } view.header.setText(Header.get(paramInt)); view.from.setText(From.get(paramInt)); view.to.setText(To.get(paramInt)); view.value.setText(Value.get(paramInt)); view.imgViewFlag.setImageResource(close.get(paramInt)); view.value.setFocusableInTouchMode(false); view.value.setFocusable(false); view.imgViewFlag.setFocusableInTouchMode(false); view.imgViewFlag.setFocusable(false); view.imgViewFlag.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub int i=paramInt+1; File f1 = new File("/data/data/com.example.converter/shared_prefs/"+i+".xml"); if(f1.exists()){ f1.delete(); Header.remove(paramInt); From.remove(paramInt); close.remove(paramInt); To.remove(paramInt); Value.remove(paramInt); } else{ for(int l = i;i<6;){ File f2 = new File("/data/data/com.example.converter/shared_prefs/"+l+".xml"); if(f2.exists()){ f2.delete(); Header.remove(paramInt); From.remove(paramInt); close.remove(paramInt); To.remove(paramInt); Value.remove(paramInt); break; } else{ l++; } } } } }); return paramView;

请帮助我,我很困惑我怎么做,我想删除该项目当我点击按钮,它不会删除当我点击按钮,这并不在该时间删除..... ......

please help me ,I'm very confused how i do it, i want to delete that item when i click on button and it does not delete when i click on button that does not delete on that time........

推荐答案

我张贴code删除从列表视图这是正常工作在我的code项目。

I am posting code for deleting item from listview which is working correctly in my code.

您忘了叫notifysetchanged完蛋了。

You forgot to call notifysetchanged thats it.

@Override public View getView(int position, View convertView, ViewGroup parent) { View row = null; LayoutInflater inflater = getLayoutInflater(); row = inflater.inflate(R.layout.one_result_details_row, parent, false); // inflate other items here : Button deleteButton = (Button) row.findViewById(R.id.Details_Button01); deleteButton.setTag(position); deleteButton.setOnClickListener( new Button.OnClickListener() { @Override public void onClick(View v) { Integer index = (Integer) view.getTag(); items.remove(index.intValue()); notifyDataSetChanged(); } } );

PLZ看看下面的答案

plz have a look at the following answers

1)删除Android中的ListView项

1) Remove ListView items in Android

2) Android的列表视图中删除所选的项

让我知道如果你仍然面临的任何问题...

Let me know if you are still facing any issue...

感谢

更多推荐

从自定义列表视图中删除项目

本文发布于:2023-11-10 22:21:08,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1576616.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:自定义   视图   项目   列表

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!