Android java.lang.ClassCastException:android.widget.RelativeLayout无法强制转换为android.widget.EditText

我在Android中遇到以下exception,点击按钮将我从一个活动带到另一个活动(我是Android开发中的新手,所以它可能不是最明亮的问题):

java.lang.ClassCastException:android.widget.RelativeLayout无法强制转换为android.widget.EditText

我已经尝试过几次清理项目了,我已经尝试过Android Tools中的Fix Project Properties选项,我已经检查了我的xml是否有错误,但我似乎无法弄清楚这一点。 我必须提一下,该按钮运行良好一段时间,直到发生此exception。

这是我的xml:

     

这是抛出exception的活动中的onCreate方法:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_customer_info); this.editMail = (EditText)findViewById(R.id.editCustomerEmail); this.editName = (EditText)findViewById(R.id.editCustomerName); this.editPhone = (EditText)findViewById(R.id.editCustomerPhone); // the exception points me here } 

你的代码说:

  

editCustomerPhone是一个relativelayout。

机器人:ID = “@ + ID / editCustomerPhone”

删除此行

从标签下方

  

你已经设置了两次。 一个用于edittext的相对布局

当我的main activity.xml没有包含我的content.xml文件的include语句时,我收到此错误。

一旦我将这些行添加回我的主activity.xml文件,一切都很好。