androidstudio“我的应用程序不断停止”

时间:2018-06-21 00:48:25

标签: android

1

我是Android Studio的初学者。请参考我的logcat图片。

enter image description here

我的问题是,当我尝试单击按钮my application keeps stopping时,为什么AVD会这样写?

2 个答案:

答案 0 :(得分:0)

从您的logcat图像中,您尝试使用以下代码将ContraintLayout转换为EditText:

EditText editText = findViewById(R.id.user_message);

这是不正确的。这是因为user_message是布局xml中ConstraintLayout的ID。请检查布局。

问题通常是由于布局中的命名约定不正确而发生的。从代码中,您将使用user_message(不是描述性的)创建ConstraintLayout的名称(这是xml中的id属性)。最好使用更具描述性的名称,例如user_message_cly,该名称可以用ConstraintLayout类型的user_message视图读取。

因此,在您的xml中,尝试将EditText重命名为user_message_edt之类。

答案 1 :(得分:0)

您需要将<?xml version="1.0" encoding="UTF-8"?> <entry xmlns:gd="http://schemas.google.com/g/2005" gd:etag="*" xmlns="http://www.w3.org/2005/Atom"> <id>http://www.google.com/m8/feeds/contacts/default/base/1785xxxx </id> <category scheme="http://schemas.google.com/g/2005#kind" term="http://schemas.google.com/contact/2008#contact" /> <gd:name> <gd:fullName>name</gd:fullName> </gd:name> <gd:email address="juli@gmail.com" displayName="juli" primary="true" rel="http://schemas.google.com/g/2005#work" /> <content type="text">Notes</content> <gd:phoneNumber primary="true" rel="http://schemas.google.com/g/2005#other">9090xxxxxx</gd:phoneNumber> </entry> 返回的视图投射为

EditText ,

findViewById()
相关问题