Reputation: 1
The Error is as below:
02-11 13:24:31.561 5262-5262/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.vicky.project, PID: 5262 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vicky.project/com.example.vicky.project.MainActivity}: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.EditText at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2646) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.EditText at com.example.vicky.project.MainActivity.onCreate(MainActivity.java:30) at android.app.Activity.performCreate(Activity.java:6662) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Upvotes: 0
Views: 2108
Reputation: 2113
Look at this carefully
{android.support.v7.widget.AppCompatTextView cannot be cast to android.widget.EditText at com.example.vicky.project.MainActivity.onCreate(MainActivity.java:30)
}
You may did this
{TextView tv = (EditText/*change this to TextView*/) findViewById (R.id.textView)
}
If you are sure your code is correct then change ID of view in layout.xml then clean project from under the build options and rebuild it.
Upvotes: 1
Reputation: 20140
Class cast Exception because you're trying to cast TextView to EditText.
Upvotes: 0