Note that there are some explanatory texts on larger screens.

plurals
  1. POAllow a button clickable when other button on other tab is clicked
    text
    copied!<p>In my android app, I have two tabs. First tab contain a button called "Save" which I already set it as <code>btn.setEnable(false)</code>.</p> <p>On the second tab I have a "Clear" button.</p> <p>So what I intend to do is when I click "Clear" button, I want the "Save" button to be clickable.</p> <p>Below Code is to show when "Clear" button is clicked.</p> <pre><code> public void Clear(View view) { StringBuilder text = new StringBuilder(); try { InputStream instream = openFileInput("myfile.txt"); if (instream != null) { InputStreamReader inputreader = new InputStreamReader(instream); BufferedReader buffreader = new BufferedReader(inputreader); File dir = getFilesDir(); File file = new File(dir, "myfile.txt"); boolean delete = file.delete(); } } catch (IOException e) { e.printStackTrace(); } Button btn=(Button)findViewById(R.id.Save); btn.setEnabled(true); TextView myTextView = (TextView) findViewById(R.id.TextView1); myTextView.setText(""); } } </code></pre> <p>Just ignore my TODO code... I am confuse about where should I put my</p> <pre><code>Button btn=(Button)findViewById(R.id.Save); btn.setEnabled(true); </code></pre> <p>The result of this code lead to app force close, logcat shows nothing. Any helps will be appreciated. Thanks</p> <p><strong>ATTEMPT:</strong> According to Vikram, after I click "Clear" button the app force to close LogCat :</p> <pre><code>07-25 13:15:02.430: W/System.err(4739): java.io.FileNotFoundException: /data/data/com.example.androidtablayout/files/myfile.txt: open failed: ENOENT (No such file or directory) 07-25 13:15:02.445: W/System.err(4739): at libcore.io.IoBridge.open(IoBridge.java:406) 07-25 13:15:02.445: W/System.err(4739): at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:78) 07-25 13:15:02.445: W/System.err(4739): at android.app.ContextImpl.openFileInput(ContextImpl.java:673) 07-25 13:15:02.445: W/System.err(4739): at android.content.ContextWrapper.openFileInput(ContextWrapper.java:159) 07-25 13:15:02.445: W/System.err(4739): at com.example.androidtablayout.HistoryActivity.ViewText(HistoryActivity.java:114) 07-25 13:15:02.445: W/System.err(4739): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:15:02.445: W/System.err(4739): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:15:02.445: W/System.err(4739): at android.view.View$1.onClick(View.java:3064) 07-25 13:15:02.445: W/System.err(4739): at android.view.View.performClick(View.java:3591) 07-25 13:15:02.445: W/System.err(4739): at android.view.View$PerformClick.run(View.java:14263) 07-25 13:15:02.445: W/System.err(4739): at android.os.Handler.handleCallback(Handler.java:605) 07-25 13:15:02.445: W/System.err(4739): at android.os.Handler.dispatchMessage(Handler.java:92) 07-25 13:15:02.445: W/System.err(4739): at android.os.Looper.loop(Looper.java:137) 07-25 13:15:02.445: W/System.err(4739): at android.app.ActivityThread.main(ActivityThread.java:4507) 07-25 13:15:02.450: W/System.err(4739): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:15:02.450: W/System.err(4739): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:15:02.455: W/System.err(4739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 07-25 13:15:02.455: W/System.err(4739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 07-25 13:15:02.455: W/System.err(4739): at dalvik.system.NativeStart.main(Native Method) 07-25 13:15:02.455: W/System.err(4739): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory) 07-25 13:15:02.460: D/dalvikvm(4739): GC_CONCURRENT freed 112K, 3% free 9418K/9671K, paused 2ms+2ms 07-25 13:15:02.460: W/System.err(4739): at libcore.io.Posix.open(Native Method) 07-25 13:15:02.460: W/System.err(4739): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110) 07-25 13:15:02.460: W/System.err(4739): at libcore.io.IoBridge.open(IoBridge.java:390) 07-25 13:15:02.460: W/System.err(4739): ... 18 more 07-25 13:15:03.730: D/Network(4739): Network 07-25 13:15:03.940: D/Network(4739): Network 07-25 13:15:04.140: D/Network(4739): Network 07-25 13:15:04.335: D/Network(4739): Network 07-25 13:15:08.215: D/AndroidRuntime(4739): Shutting down VM 07-25 13:15:08.215: W/dalvikvm(4739): threadid=1: thread exiting with uncaught exception (group=0x40c3e1f8) 07-25 13:15:08.220: E/AndroidRuntime(4739): FATAL EXCEPTION: main 07-25 13:15:08.220: E/AndroidRuntime(4739): java.lang.IllegalStateException: Could not execute method of the activity 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.view.View$1.onClick(View.java:3069) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.view.View.performClick(View.java:3591) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.view.View$PerformClick.run(View.java:14263) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.os.Handler.handleCallback(Handler.java:605) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.os.Handler.dispatchMessage(Handler.java:92) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.os.Looper.loop(Looper.java:137) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.app.ActivityThread.main(ActivityThread.java:4507) 07-25 13:15:08.220: E/AndroidRuntime(4739): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:15:08.220: E/AndroidRuntime(4739): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:15:08.220: E/AndroidRuntime(4739): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 07-25 13:15:08.220: E/AndroidRuntime(4739): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 07-25 13:15:08.220: E/AndroidRuntime(4739): at dalvik.system.NativeStart.main(Native Method) 07-25 13:15:08.220: E/AndroidRuntime(4739): Caused by: java.lang.reflect.InvocationTargetException 07-25 13:15:08.220: E/AndroidRuntime(4739): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:15:08.220: E/AndroidRuntime(4739): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:15:08.220: E/AndroidRuntime(4739): at android.view.View$1.onClick(View.java:3064) 07-25 13:15:08.220: E/AndroidRuntime(4739): ... 11 more 07-25 13:15:08.220: E/AndroidRuntime(4739): Caused by: java.lang.NullPointerException 07-25 13:15:08.220: E/AndroidRuntime(4739): at com.example.androidtablayout.HistoryActivity.Clear(HistoryActivity.java:172) 07-25 13:15:08.220: E/AndroidRuntime(4739): ... 14 more </code></pre> <p>Acoording to Tarsem, app force to close :</p> <p>**</p> <pre><code>07-25 13:25:56.960: D/Network(6667): Network 07-25 13:25:57.000: D/dalvikvm(6667): GC_CONCURRENT freed 112K, 3% free 9417K/9671K, paused 2ms+3ms 07-25 13:25:57.155: D/Network(6667): Network 07-25 13:25:57.315: D/Network(6667): Network 07-25 13:25:57.440: D/Network(6667): Network 07-25 13:25:59.010: D/AndroidRuntime(6667): Shutting down VM 07-25 13:25:59.010: W/dalvikvm(6667): threadid=1: thread exiting with uncaught exception (group=0x40c3e1f8) 07-25 13:25:59.020: E/AndroidRuntime(6667): FATAL EXCEPTION: main 07-25 13:25:59.020: E/AndroidRuntime(6667): java.lang.IllegalStateException: Could not execute method of the activity 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.view.View$1.onClick(View.java:3069) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.view.View.performClick(View.java:3591) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.view.View$PerformClick.run(View.java:14263) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.os.Handler.handleCallback(Handler.java:605) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.os.Handler.dispatchMessage(Handler.java:92) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.os.Looper.loop(Looper.java:137) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.app.ActivityThread.main(ActivityThread.java:4507) 07-25 13:25:59.020: E/AndroidRuntime(6667): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:25:59.020: E/AndroidRuntime(6667): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:25:59.020: E/AndroidRuntime(6667): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:790) 07-25 13:25:59.020: E/AndroidRuntime(6667): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557) 07-25 13:25:59.020: E/AndroidRuntime(6667): at dalvik.system.NativeStart.main(Native Method) 07-25 13:25:59.020: E/AndroidRuntime(6667): Caused by: java.lang.reflect.InvocationTargetException 07-25 13:25:59.020: E/AndroidRuntime(6667): at java.lang.reflect.Method.invokeNative(Native Method) 07-25 13:25:59.020: E/AndroidRuntime(6667): at java.lang.reflect.Method.invoke(Method.java:511) 07-25 13:25:59.020: E/AndroidRuntime(6667): at android.view.View$1.onClick(View.java:3064) 07-25 13:25:59.020: E/AndroidRuntime(6667): ... 11 more 07-25 13:25:59.020: E/AndroidRuntime(6667): Caused by: java.lang.NullPointerException 07-25 13:25:59.020: E/AndroidRuntime(6667): at com.example.androidtablayout.HistoryActivity.Clear(HistoryActivity.java:171) 07-25 13:25:59.020: E/AndroidRuntime(6667): ... 14 more </code></pre> <p>**</p>
 

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