Unfortunately, <App name> has stopped working. Android?Eclipse application -


i writting simple converter app, worked fine sometime on mobile when disconnected , reconnected laptop stopped working displaying above message.

here's code:

package com.example.myfirstapp;  import android.os.bundle; import android.app.activity; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext;  public class mainactivity extends activity {      @override      protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_main);          final edittext editcentimeters = (edittext) findviewbyid(r.id.editcent);          final edittext editinches = (edittext) findviewbyid(r.id.editinch);          button buttonconvert = (button) findviewbyid(r.id.buttonconvert);          buttonconvert.setonclicklistener(new onclicklistener() {              @override             public void onclick(view arg0) {                  double centi = double.valueof(editcentimeters.gettext().tostring());                  double inches= centi * 0.3937007 ;                  editinches.settext(string.valueof(inches));                }         });     }    } 

this logcat

07-23 23:54:42.624: d/dalvikvm(12601): late-enabling checkjni 07-23 23:54:43.745: d/androidruntime(12601): shutting down vm 07-23 23:54:43.745: w/dalvikvm(12601): threadid=1: thread exiting uncaught exception (group=0x40a72228) 07-23 23:54:43.765: e/androidruntime(12601): fatal exception: main 07-23 23:54:43.765: e/androidruntime(12601): java.lang.runtimeexception: unable start activity componentinfo{com.example.myfirstapp/com.example.myfirstapp.mainactivity}: java.lang.classcastexception: android.widget.textview cannot cast android.widget.edittext 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2205) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread.handlelaunchactivity(activitythread.java:2240) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread.access$600(activitythread.java:139) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread$h.handlemessage(activitythread.java:1262) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.os.handler.dispatchmessage(handler.java:99) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.os.looper.loop(looper.java:156) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread.main(activitythread.java:4987) 07-23 23:54:43.765: e/androidruntime(12601):    @ java.lang.reflect.method.invokenative(native method) 07-23 23:54:43.765: e/androidruntime(12601):    @ java.lang.reflect.method.invoke(method.java:511) 07-23 23:54:43.765: e/androidruntime(12601):    @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:784) 07-23 23:54:43.765: e/androidruntime(12601):    @ com.android.internal.os.zygoteinit.main(zygoteinit.java:551) 07-23 23:54:43.765: e/androidruntime(12601):    @ dalvik.system.nativestart.main(native method) 07-23 23:54:43.765: e/androidruntime(12601): caused by: java.lang.classcastexception: android.widget.textview cannot cast android.widget.edittext 07-23 23:54:43.765: e/androidruntime(12601):    @ com.example.myfirstapp.mainactivity.oncreate(mainactivity.java:18) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activity.performcreate(activity.java:4538) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1071) 07-23 23:54:43.765: e/androidruntime(12601):    @ android.app.activitythread.performlaunchactivity(activitythread.java:2161) 07-23 23:54:43.765: e/androidruntime(12601):    ... 11 more 

can tell me problem is? new android , first app may silly mistake doing please explain error , how fix it?

thanks in advance!

  final edittext editcentimeters = (edittext) findviewbyid(r.id.editcent); 

line 18 (counted...) textview in xml. change edittext

if made sure edittext in xml. eclipse -> project -> clean.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -