我想在我的中使用 clear() CostomArrayAdapter
,但我总是得到这个错误:
09-08 18:15:01.960: E/AndroidRuntime(27192): FATAL EXCEPTION: main
09-08 18:15:01.960: E/AndroidRuntime(27192): java.lang.UnsupportedOperationException
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.util.AbstractList.remove(AbstractList.java:638)
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.util.AbstractList$SimpleListIterator.remove(AbstractList.java:75)
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.util.AbstractList.removeRange(AbstractList.java:658)
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.util.AbstractList.clear(AbstractList.java:466)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.ArrayAdapter.clear(ArrayAdapter.java:258)
09-08 18:15:01.960: E/AndroidRuntime(27192): at de.fterhorst.pictoriusvertretungsplan.SimpleArrayadapterDay.dayempty(SimpleArrayadapterDay.java:235)
09-08 18:15:01.960: E/AndroidRuntime(27192): at de.fterhorst.pictoriusvertretungsplan.SimpleArrayadapterDay.getView(SimpleArrayadapterDay.java:177)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.AbsListView.obtainView(AbsListView.java:2177)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.ListView.makeAndAddView(ListView.java:1840)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.ListView.fillDown(ListView.java:675)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.ListView.fillFromTop(ListView.java:736)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.ListView.layoutChildren(ListView.java:1655)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.AbsListView.onLayout(AbsListView.java:2012)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.View.layout(View.java:14289)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.View.layout(View.java:14289)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.View.layout(View.java:14289)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-08 18:15:01.960: E/AndroidRuntime(27192): at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:349)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.View.layout(View.java:14289)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.View.layout(View.java:14289)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewGroup.layout(ViewGroup.java:4559)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1976)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1730)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.Choreographer.doFrame(Choreographer.java:532)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.os.Handler.handleCallback(Handler.java:730)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.os.Handler.dispatchMessage(Handler.java:92)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.os.Looper.loop(Looper.java:137)
09-08 18:15:01.960: E/AndroidRuntime(27192): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.lang.reflect.Method.invokeNative(Native Method)
09-08 18:15:01.960: E/AndroidRuntime(27192): at java.lang.reflect.Method.invoke(Method.java:525)
09-08 18:15:01.960: E/AndroidRuntime(27192): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-08 18:15:01.960: E/AndroidRuntime(27192): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-08 18:15:01.960: E/AndroidRuntime(27192): at dalvik.system.NativeStart.main(Native Method)
当我这样做时:
this.clear(); this.notifyDataSetChanged();
在我的ArrayAdapter
:
public class CostomArrayAdapter extends ArrayAdapter<String>
我可以在 arrayadapter 上使用 clear(),我希望有人可以帮助我。