I have a simple problem with my small calculator in Android studio (below is my code).
When I run it in the emulator app stop working. Can someone help me?
package com.blah-blah.padideh.tamrin3; Import android App Importroid.os.Bundle; Import android.view.View; Import android.widget.Button; Import android.widget.TextView; Increases public class activity on activity {Calculation of the button = (button) SearchVBIID (R.B.ton); TextView firstnumber = (TextView) findViewById (R.id.editText); TextView Secondnumber = (TextView) Find VVBID (RIDActit2); Text view result = (text view) Find VVIIID (RID reset); Double number 1, number 2; @ Override Protected Zero (Bundle Saved Instantstate) {Super. NET (Saved Instantstate); SetContentView (R.layout.activity_farshid); Calculate.setOnClickListener (see the new OnClickListener () {@Override click on Public Zero (see V) {num1 = Double .apad double (first number .gettext (). ToString ()); num2 = double.parseDouble (secondnumber. GetText (). ToString (); Results .set text ("sum: \ t" + (num1 + num2) + "\ n" + "multiple: \ t" + (num1 * num2) + "\ n" + "Zero: \ t" + (Num1-num2) + "\ n" + "Split: \ t" + (num1 / num2) + "\ n" + "Good Luck");}}); }}
package com.blah-blah.padideh.tamrin3;
Import android.app.activity; Importroid.os.Bundle; Import android.view.View; Import android.widget.Button; Import android.widget.TextView;
the public class increases activityone activity {@ override protected zero creation (bundle savedinstenstate) {super.onCreate (SavedInstanceState); SetContentView (R.layout.activity_farshid); // Now you can find your ideas button count = (button) findViewById (R.id.button); Find Last Textview FirstNumber = (Text View) VVBID (RID Edit Text); Find final textview secondsnumber = (text view) VVBIID (RID.EditTet 2); Text view result = (text view) Find VVIIID (RID reset); Last double number 1, number 2; Calculate.setOnClickListener (see the new OnClickListener () {@Override click on Public Zero (see V) {num1 = Double .apad double (first number .gettext (). ToString ()); num2 = double.parseDouble (secondnumber. GetText (). ToString (); Results .set text ("sum: \ t" + (num1 + num2) + "\ n" + "multiple: \ t" + (num1 * num2) + "\ n" + "Zero: \ t" + (Num1-num2) + "\ n" + "Split: \ t" + (num1 / num2) + "\ n" + "Good Luck");}}); }}
You can not try to find a view in an activity before calling setContentView ().
No comments:
Post a Comment