Android java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.EditText

蹲街弑〆低调 提交于 2019-12-02 02:22:50

you code says :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/editCustomerPhone"

editCustomerPhone is a relativelayout.

Sush

android:id="@+id/editCustomerPhone"

remove this line

from below tag

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:tools="http://schemas.android.com/tools"
     android:id="@+id/editCustomerPhone"
     android:layout_width="match_parent"
     android:layout_height="match_parent"
     android:background="@android:color/background_dark"
     android:paddingBottom="@dimen/activity_vertical_margin"
     android:paddingLeft="@dimen/activity_horizontal_margin"
     android:paddingRight="@dimen/activity_horizontal_margin"
     android:paddingTop="@dimen/activity_vertical_margin"
     tools:context=".CustomerInfoActivity" >

you have set it twice. One for relative layout one for edittext

I received this error when my main activity.xml did not have the include statement to my content.xml file.

Once i added these lines back into my main activity.xml file, everything was fine again.

    <include
    android:id="@+id/editText"
    layout="@layout/content" />
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!