gpt4 book ai didi

android - 错误 : "Cannot resolve symbol ' @string/edit_message' "Android Studio

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:37:22 26 4
gpt4 key购买 nike

我正在尝试按照以下 android 教程进行操作:http://developer.android.com/training/basics/firstapp/building-ui.html但是当我到达必须添加按钮的部分时,我的 Android Studio 不断返回此错误:

Cannot resolve symbol '@string/edit_message'
Cannot resolve symbol '@string/button_send'

XML 代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send" />
</LinearLayout>

我在这里做错了什么?我找不到关于其他 stackoverflow 问题的正确解决方案,我很确定我在 android 教程中使用了正确的代码来自谷歌。

最佳答案

您必须在 strings.xml 中定义这 2 个字符串

     <?xml version="1.0" encoding="utf-8"?>
<resources>
...
<string name="edit_message">something text /string>
<string name="button_send">something text</string>
...
</resources>

关于android - 错误 : "Cannot resolve symbol ' @string/edit_message' "Android Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27778304/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com