Note that there are some explanatory texts on larger screens.

plurals
  1. POInclude Calculator activity inside a Sherlock fragment
    primarykey
    data
    text
    <p>Hi I'm working on a launcher for education and I have a calculator activity and xml layout file I want to include in the fragmenttab2 I am using the include layout in the xml and it shows up fine but when I click a button say the number 3 the app crashes what am I doing wrong?</p> <p>fragmenttab2.xml</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg" &gt; &lt;include android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" layout="@layout/activity_calculator" /&gt; &lt;Button android:id="@+id/app" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:background="@drawable/allapps" /&gt; &lt;Button android:id="@+id/tools" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/tools" /&gt; &lt;Button android:id="@+id/web" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentLeft="true" android:background="@drawable/internet" /&gt; &lt;/RelativeLayout&gt; </code></pre> <p>Calculator Buttons:</p> <pre><code>button0=(Button)findViewById(R.id.button0); button1=(Button)findViewById(R.id.engery); button2=(Button)findViewById(R.id.heatcal); button3=(Button)findViewById(R.id.tempcal); button4=(Button)findViewById(R.id.button4); button5=(Button)findViewById(R.id.button5); button6=(Button)findViewById(R.id.button6); button7=(Button)findViewById(R.id.button7); button8=(Button)findViewById(R.id.button8); button9=(Button)findViewById(R.id.button9); buttonPlus=(Button)findViewById(R.id.buttonPlus); buttonMinus=(Button)findViewById(R.id.buttonMinus); buttonMultiply=(Button)findViewById(R.id.buttonMultiply); buttonDivide=(Button)findViewById(R.id.buttonDivide); buttonPoint=(Button)findViewById(R.id.buttonPoint); buttonEqual=(Button)findViewById(R.id.buttonEqual); vibrator = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE); //button_del=(Button)findViewById(R.id.button_del) </code></pre> <p>;</p> <p><img src="https://i.stack.imgur.com/ABrC1.jpg" alt="enter image description here"></p> <p>LogCat:</p> <pre><code>09-22 00:18:53.036: D/AndroidRuntime(1578): Shutting down VM 09-22 00:18:53.036: W/dalvikvm(1578): threadid=1: thread exiting with uncaught exception (group=0x40a71930) 09-22 00:18:53.076: E/AndroidRuntime(1578): FATAL EXCEPTION: main 09-22 00:18:53.076: E/AndroidRuntime(1578): java.lang.IllegalStateException: Could not find a method onClickListener7(View) in the activity class com.d4a.stzh.MainActivity for onClick handler on view class android.widget.Button with id 'button7' 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.view.View$1.onClick(View.java:3586) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.view.View.performClick(View.java:4204) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.view.View$PerformClick.run(View.java:17355) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.os.Handler.handleCallback(Handler.java:725) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.os.Handler.dispatchMessage(Handler.java:92) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.os.Looper.loop(Looper.java:137) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.app.ActivityThread.main(ActivityThread.java:5041) 09-22 00:18:53.076: E/AndroidRuntime(1578): at java.lang.reflect.Method.invokeNative(Native Method) 09-22 00:18:53.076: E/AndroidRuntime(1578): at java.lang.reflect.Method.invoke(Method.java:511) 09-22 00:18:53.076: E/AndroidRuntime(1578): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793) 09-22 00:18:53.076: E/AndroidRuntime(1578): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560) 09-22 00:18:53.076: E/AndroidRuntime(1578): at dalvik.system.NativeStart.main(Native Method) 09-22 00:18:53.076: E/AndroidRuntime(1578): Caused by: java.lang.NoSuchMethodException: onClickListener7 [class android.view.View] 09-22 00:18:53.076: E/AndroidRuntime(1578): at java.lang.Class.getConstructorOrMethod(Class.java:460) 09-22 00:18:53.076: E/AndroidRuntime(1578): at java.lang.Class.getMethod(Class.java:915) 09-22 00:18:53.076: E/AndroidRuntime(1578): at android.view.View$1.onClick(View.java:3579) 09-22 00:18:53.076: E/AndroidRuntime(1578): </code></pre> <p>any help would Be amazing i'm still new to android so please don't judge </p> <p>Rapsong11</p>
    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.
    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