eclipse - Program crashing on click of a button Android Error -
hey trying make once click button, calculates , changes edittext answer. when clicked button, program crashed! please me, new android.
java code:
public class areacircle extends activity { textview radiustextview; textview areatextview; edittext radiusedittext; button areabutton; edittext answeredittext; @override public void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); setcontentview(r.layout.areacircle); areabutton = (button) findviewbyid(r.id.areabutton); answeredittext = (edittext) findviewbyid(r.id.answeredittext); radiusedittext = (edittext) findviewbyid(r.id.radiusedittext); } public void findarea(){ answeredittext = (edittext) findviewbyid(r.id.answeredittext); double pi = math.pi; double radius = double.parsedouble(radiusedittext.gettext().tostring()); double finalradius = radius * radius *pi; answeredittext.settext(string.valueof(finalradius)); } }
here logcat contents:
08-28 14:41:06.558: e/trace(823): error opening trace file: no such file or directory (2) 08-28 14:41:09.876: d/gralloc_goldfish(823): emulator without gpu emulation detected. 08-28 14:41:13.677: d/dalvikvm(823): gc_concurrent freed 152k, 10% free 2613k/2896k, paused 5ms+6ms, total 507ms 08-28 14:41:13.677: i/choreographer(823): skipped 37 frames! application may doing work on main thread. 08-28 14:41:23.655: i/choreographer(823): skipped 31 frames! application may doing work on main thread. 08-28 14:41:30.986: d/androidruntime(823): shutting down vm 08-28 14:41:30.986: w/dalvikvm(823): threadid=1: thread exiting uncaught exception (group=0x40a71930) 08-28 14:41:31.035: e/androidruntime(823): fatal exception: main 08-28 14:41:31.035: e/androidruntime(823): java.lang.illegalstateexception: not find method findarea(view) in activity class com.turnapps.essentials.areacircle onclick handler on view class android.widget.button id 'areabutton' 08-28 14:41:31.035: e/androidruntime(823): @ android.view.view$1.onclick(view.java:3586) 08-28 14:41:31.035: e/androidruntime(823): @ android.view.view.performclick(view.java:4204) 08-28 14:41:31.035: e/androidruntime(823): @ android.view.view$performclick.run(view.java:17355) 08-28 14:41:31.035: e/androidruntime(823): @ android.os.handler.handlecallback(handler.java:725) 08-28 14:41:31.035: e/androidruntime(823): @ android.os.handler.dispatchmessage(handler.java:92) 08-28 14:41:31.035: e/androidruntime(823): @ android.os.looper.loop(looper.java:137) 08-28 14:41:31.035: e/androidruntime(823): @ android.app.activitythread.main(activitythread.java:5041) 08-28 14:41:31.035: e/androidruntime(823): @ java.lang.reflect.method.invokenative(native method) 08-28 14:41:31.035: e/androidruntime(823): @ java.lang.reflect.method.invoke(method.java:511) 08-28 14:41:31.035: e/androidruntime(823): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:793) 08-28 14:41:31.035: e/androidruntime(823): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:560) 08-28 14:41:31.035: e/androidruntime(823): @ dalvik.system.nativestart.main(native method) 08-28 14:41:31.035: e/androidruntime(823): caused by: java.lang.nosuchmethodexception: findarea [class android.view.view] 08-28 14:41:31.035: e/androidruntime(823): @ java.lang.class.getconstructorormethod(class.java:460) 08-28 14:41:31.035: e/androidruntime(823): @ java.lang.class.getmethod(class.java:915) 08-28 14:41:31.035: e/androidruntime(823): @ android.view.view$1.onclick(view.java:3579) 08-28 14:41:31.035: e/androidruntime(823): ... 11 more
you have declared onclick="findarea"
propertis button. correct signature takes view paramter. change
public void findarea(){
with
public void findarea(view view){
Comments
Post a Comment