Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/219.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 模拟器中的硬编码警告_Android_Android Emulator - Fatal编程技术网

Android 模拟器中的硬编码警告

Android 模拟器中的硬编码警告,android,android-emulator,Android,Android Emulator,我收到这样的警告: 硬编码字符串“按钮名称”应使用@string资源 这是什么意思? 如果我保持原样,应用程序中是否存在任何问题(特别是与gps相关的问题) 这是按钮: android:id="@+id/retrieve_location_button" android:text="Retrieve Location" android:layout_width="wrap_content" android:layout_height="wrap_content" 这意味着按钮的布局XML应该如

我收到这样的警告:

硬编码字符串“按钮名称”应使用@string资源

这是什么意思? 如果我保持原样,应用程序中是否存在任何问题(特别是与gps相关的问题)

这是按钮:

android:id="@+id/retrieve_location_button"
android:text="Retrieve Location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"

这意味着按钮的布局XML应该如下所示:

<button android:id="@+id/retrieve_location_button" android:text="@string/location_text" android:layout_width="wrap_content" android:layout_height="wrap_content">

其中您的strings.xml将具有:

<resources>
    <string name="location_text">Retrieve Location</string>
</resources>

检索位置

这是一个国际化和翻译问题,而不是影响程序运行时的问题。您应该将用户可见字符串外部化,以便可以翻译应用程序。

这只是一个警告。。也可以忽略。。但它的意思是。。安装使用硬编码值,如android:text=“检索位置”。。您可以将此值存储在res/values文件夹中,然后使用。。