如何从字符串数组列表中删除字符串,ANDROID [英] how to remove a string from arraylist of strings, ANDROID
问题描述
我创建了一个字符串数组列表
I created an arraylist of strings
List<String> textArray = new ArrayList<String>();
然后我将字符串(我从edittext获取)添加到textArray,如下所示
and then I added the strings(which I am getting from edittext) to textArray as follows
String text = editText1.getText().toString();
textArray.add(text);
现在我创建了一个按钮,需要在单击按钮时从数组中删除字符串.但我不知道该怎么做.我知道对于位图数组,我们使用回收从数组中清除位图,但请建议我如何从数组列表中删除或清除字符串.
Now I created a button and need to remove the string from the array when the button is clicked.But i dont know what to do. I know for arrays of bitmaps we clear a bitmap from array using recycle but Please suggest me how to remove or clear the string from arraylist.
推荐答案
您可以拨打以下电话之一:
You can call one of:
删除所有条目
textArray.clear();
从特定位置移除(例如第一项)
to remove from a specific position (e.g. first item)
textArray.remove(0);
删除一个特定的字符串(那个等于
你的)
to remove a specific string (that equals
yours)
textArray.remove("myString");
这篇关于如何从字符串数组列表中删除字符串,ANDROID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!