Note that there are some explanatory texts on larger screens.

plurals
  1. POCrash on hiding View
    primarykey
    data
    text
    <p>I have a search bar at the top of a listview and there is an action button which toggles the visibility of the search bar...</p> <p>The search bar is shown correctly, however when I hide it the app crashes. This is the code to toggle the view...</p> <pre><code>/** * Show / Hide the search box */ private void toggleSearch() { //in the instance there are not customers...a crash will occur when searching if(customers.length &gt; 0) { if(searchVisible)//hide the search bar { searchFrame.setVisibility(View.GONE); Log.i("SEARCH", "HIDDEN"); searchVisible = false; Log.i("SEARCH", "BOOLEAN SET"); resetList(); Log.i("SEARCH", "LIST RESET?"); } else//show the search bar { searchFrame.setVisibility(View.VISIBLE); searchVisible = true; } } } </code></pre> <p>and here is the LogCat output...</p> <pre><code>11-18 11:33:22.483: I/SEARCH(1591): SHOWN 11-18 11:33:22.493: D/audio_hw_primary(183): select_devices: out_snd_device(4: headphones) in_snd_device(0: ) 11-18 11:33:22.753: D/audio_hw_primary(183): out_set_parameters: enter: usecase(0: deep-buffer-playback) kvpairs: routing=4 11-18 11:33:24.473: I/SEARCH(1591): HIDDEN 11-18 11:33:24.473: I/SEARCH(1591): BOOLEAN SET 11-18 11:33:24.473: I/SEARCH(1591): LIST RESET? 11-18 11:33:24.473: D/AndroidRuntime(1591): Shutting down VM 11-18 11:33:24.473: E/AndroidRuntime(1591): FATAL EXCEPTION: main 11-18 11:33:24.473: E/AndroidRuntime(1591): Process: evans.louis.firstdroid, PID: 1591 11-18 11:33:24.473: E/AndroidRuntime(1591): java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:392) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.AbsListView.obtainView(AbsListView.java:2263) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.ListView.measureHeightOfChildren(ListView.java:1263) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.ListView.onMeasure(ListView.java:1175) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.View.measure(View.java:16458) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.View.measure(View.java:16458) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.View.measure(View.java:16458) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) 11-18 11:33:24.473: E/AndroidRuntime(1591): at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:327) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.View.measure(View.java:16458) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310) 11-18 11:33:24.473: E/AndroidRuntime(1591): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2289) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.View.measure(View.java:16458) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1914) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1111) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1293) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:998) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5582) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.Choreographer.doCallbacks(Choreographer.java:562) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.Choreographer.doFrame(Choreographer.java:532) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.os.Handler.handleCallback(Handler.java:733) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.os.Handler.dispatchMessage(Handler.java:95) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.os.Looper.loop(Looper.java:137) 11-18 11:33:24.473: E/AndroidRuntime(1591): at android.app.ActivityThread.main(ActivityThread.java:4998) 11-18 11:33:24.473: E/AndroidRuntime(1591): at java.lang.reflect.Method.invoke(Native Method) 11-18 11:33:24.473: E/AndroidRuntime(1591): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777) 11-18 11:33:24.473: E/AndroidRuntime(1591): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593) 11-18 11:33:24.483: W/ActivityManager(609): Force finishing activity evans.louis.firstdroid/com.firsthosted.firstdroid.CustomerList </code></pre> <p>any ideas?</p> <p>Thanks</p> <p>EDIT: here is resetList() as requested</p> <pre><code>/** * Revert the ListView to it's original order */ private void resetList() { try { adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.listview_container, R.id.name, customers); lv.setAdapter(adapter); } catch(Exception e) { Library.errorHandler("resetList", e); } } </code></pre>
    singulars
    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.
    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