Note that there are some explanatory texts on larger screens.

plurals
  1. PORemove All items (visible and not visible) Custom listview Android?
    primarykey
    data
    text
    <p>I have problem in my code.I want remove all items in custom <code>listview</code> with this code :</p> <pre><code>public void delete_all() { int count = getCount(); if(count&gt;0) { for (int i = 0; i &lt; count; i++) { data.remove(data.get(i)); } notifyDataSetChanged(); } } public Object getItem(int position) { return position; } </code></pre> <p>but the result, just <strong>items visible</strong> where deleted , example : there <strong>count</strong> = 5 item , the result just 3 <strong>items visible</strong> are deleted, and 2 items in not deleted,</p> <pre><code>data.remove(data.get(i)); </code></pre> <p>i try too change with <code>data.remove(i);</code> i same result;</p> <p>and logcat of that code is </p> <pre><code>&gt; 04-15 13:07:58.340: E/AndroidRuntime(2111): FATAL EXCEPTION: main 04-15 13:07:58.340: E/AndroidRuntime(2111): java.lang.IllegalStateException: Could not execute method of the activity 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.view.View$1.onClick(View.java:3044) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.view.View.performClick(View.java:3511) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.view.View$PerformClick.run(View.java:14105) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.os.Handler.handleCallback(Handler.java:605) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.os.Handler.dispatchMessage(Handler.java:92) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.os.Looper.loop(Looper.java:137) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.app.ActivityThread.main(ActivityThread.java:4456) 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.lang.reflect.Method.invokeNative(Native Method) 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.lang.reflect.Method.invoke(Method.java:511) 04-15 13:07:58.340: E/AndroidRuntime(2111): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787) 04-15 13:07:58.340: E/AndroidRuntime(2111): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554) 04-15 13:07:58.340: E/AndroidRuntime(2111): at dalvik.system.NativeStart.main(Native Method) 04-15 13:07:58.340: E/AndroidRuntime(2111): Caused by: java.lang.reflect.InvocationTargetException 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.lang.reflect.Method.invokeNative(Native Method) 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.lang.reflect.Method.invoke(Method.java:511) 04-15 13:07:58.340: E/AndroidRuntime(2111): at android.view.View$1.onClick(View.java:3039) 04-15 13:07:58.340: E/AndroidRuntime(2111): ... 11 more 04-15 13:07:58.340: E/AndroidRuntime(2111): **Caused by: java.lang.IndexOutOfBoundsException: Invalid index 3, size is 2** 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251) 04-15 13:07:58.340: E/AndroidRuntime(2111): at java.util.ArrayList.get(ArrayList.java:304) 04-15 13:07:58.340: E/AndroidRuntime(2111): at com.droidersuin.imagelistfromurl.LazyAdapter.delete_all(LazyAdapter.java:60) 04-15 13:07:58.340: E/AndroidRuntime(2111): at com.droidersuin.app.SearchActivity.search(SearchActivity.java:306) 04-15 13:07:58.340: E/AndroidRuntime(2111): ... 14 more </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload