如何从字符串数组列表中删除字符串,ANDROID [英] how to remove a string from arraylist of strings, ANDROID
问题描述
我创建的字符串的ArrayList
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);
现在我创建了一个按钮,并需要删除从数组中的字符串时,按钮clicked.But我不知道该怎么办。
我知道的位图阵列使用我们回收清除阵列中的位图,但请建议我如何删除或从ArrayList中清除字符串。
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.
推荐答案
您可以拨打之一:
要删除所有条目
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屋!