Friday, 15 July 2011

java - Android Activity: Input number, press button, pass from the xml to the class -


Hello!
Trying to input a number in the editing test field, press calc531button and two variables to input that number.

xml:

  & lt; EditText Android: inputType = "numberDecimal" Android: id = "@ + id / inputField" Android: layout_below = "@ + id / title5" /> & Lt; Button style = "Android: attr / buttonStyleSmall" Android: text = "calculate" Android: id = "@ + id / calcBtn" Android: onClick = "inputField" />  

java:

  Crate on protected void (bundled saved instenstate) {super.onCreate (savedInstanceState); SetContentView (R.layout.activity_five); See. OnClickListener calcButton = New View.OnClickListener () {public void onClick (see v) {textHold = (EditText) findViewById (R.id.inputField); StringHold = textHold.getText (). ToString (); Input double = double. Prsd double (stringhold); }};  

Login error:

  java.lang.IllegalStateException: The reason found by a method squat1RMinputField (see) ......... was not found : Java.lang.NoSuchMethodException: inputField [class android.view.View]  

Any help would be greatly appreciated!

If you already have the android: onClick = "inputfilled" "inside the XML button , you should enter the inputField method in your activity Need to implement.

  Find public zero input field (see V) {textHold = (EditText) FindVBIID (RID input field); StringHold = textHold.getText (). ToString (); input Double = double. Piarsdi double (Stringhold);}  

and Nikalenkonklik Lester Club Bttn ... and onCreate () Remove Idi.


No comments:

Post a Comment