ArrayAdapter 删除不起作用
我有一个列表视图,当用户单击删除按钮时,该列表视图将被 。 由于某种原因我收到此错误
02-19 17:16:47.231: E/AndroidRuntime(1118): 致命异常:main 02-19 17:16:47.231: E/AndroidRuntime(1118): java.lang.UnsupportedOperationException 02-19 17:16:47.231:E / AndroidRuntime(1118):在java.util.AbstractList.remove(AbstractList.java:645) 02-19 17:16:47.231:E / AndroidRuntime(1118):在java.util.AbstractList $ SimpleListIterator.remove(AbstractList.java:77) 02-19 17:16:47.231:E / AndroidRuntime(1118):在java.util.AbstractCollection.remove(AbstractCollection.java:230) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.widget.ArrayAdapter.remove(ArrayAdapter.java:212) 02-19 17:16:47.231:E / AndroidRuntime(1118):在com.DCWebMakers.Vairon.ManageAppointment.onClick(ManageAppointment.java:102) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.view.View.performClick(View.java:2485) 02-19 17:16:47.231: E/AndroidRuntime(1118): 在 android.view.View$PerformClick.run(View.java:9080) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.os.Handler.handleCallback(Handler.java:587) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.os.Handler.dispatchMessage(Handler.java:92) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.os.Looper.loop(Looper.java:123) 02-19 17:16:47.231:E / AndroidRuntime(1118):在android.app.ActivityThread.main(ActivityThread.java:3683) 02-19 17:16:47.231:E / AndroidRuntime(1118):在java.lang.reflect.Method.invokeNative(本机方法) 02-19 17:16:47.231:E / AndroidRuntime(1118):在java.lang.reflect.Method.invoke(Method.java:507) 02-19 17:16:47.231: E/AndroidRuntime(1118): 在 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839) 02-19 17:16:47.231:E / AndroidRuntime(1118):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 02-19 17:16:47.231:E / AndroidRuntime(1118):在dalvik.system.NativeStart.main(本机方法)
这是删除项目时的代码。
detailAdapter.remove(eDelete.getText().toString());
detailAdapter.notifyDataSetChanged();
Possible Duplicate:
UnsupportedOperationException with ArrayAdapter.remove
I have a listview which will be refreshed when the user clicks a delete button.
For some reason I get this error
02-19 17:16:47.231: E/AndroidRuntime(1118): FATAL EXCEPTION: main
02-19 17:16:47.231: E/AndroidRuntime(1118): java.lang.UnsupportedOperationException
02-19 17:16:47.231: E/AndroidRuntime(1118): at java.util.AbstractList.remove(AbstractList.java:645)
02-19 17:16:47.231: E/AndroidRuntime(1118): at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:77)
02-19 17:16:47.231: E/AndroidRuntime(1118): at java.util.AbstractCollection.remove(AbstractCollection.java:230)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.widget.ArrayAdapter.remove(ArrayAdapter.java:212)
02-19 17:16:47.231: E/AndroidRuntime(1118): at com.DCWebMakers.Vairon.ManageAppointment.onClick(ManageAppointment.java:102)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.view.View.performClick(View.java:2485)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.view.View$PerformClick.run(View.java:9080)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.os.Handler.handleCallback(Handler.java:587)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.os.Handler.dispatchMessage(Handler.java:92)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.os.Looper.loop(Looper.java:123)
02-19 17:16:47.231: E/AndroidRuntime(1118): at android.app.ActivityThread.main(ActivityThread.java:3683)
02-19 17:16:47.231: E/AndroidRuntime(1118): at java.lang.reflect.Method.invokeNative(Native Method)
02-19 17:16:47.231: E/AndroidRuntime(1118): at java.lang.reflect.Method.invoke(Method.java:507)
02-19 17:16:47.231: E/AndroidRuntime(1118): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
02-19 17:16:47.231: E/AndroidRuntime(1118): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
02-19 17:16:47.231: E/AndroidRuntime(1118): at dalvik.system.NativeStart.main(Native Method)
This is the code when removing the item.
detailAdapter.remove(eDelete.getText().toString());
detailAdapter.notifyDataSetChanged();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从堆栈跟踪来看,支持 ArrayAdapter 的列表不支持删除。您使用什么类型的列表?
Judging by the stack trace, the list that is backing your
ArrayAdapter
does not support removal. What type of list are you using?