2016-07-22 167 views
0
Note: This string resource has the same name as the element ID: edit_message. However, references to resources are always scoped by the resource type (such as id or string), so using the same name does not cause collisions. " 

在上面什么呢给出文本“引用资源总是作用域”在上下文中是指以下XML片段添加字符串资源

<EditText android:id="@+id/edit_message" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:hint="@string/edit_message" /> 
+0

恩,给我们看你的strings.xml文件....? – Razgriz

+0

保持更改edit_message在String.xml文件中的edit_mes并尝试在编辑文本提示中使用android:hint =“@ string/edit_mes” –

回答

0

作用域@id/@string/

你的两个ID都是相同的,但它们不会因为它们在不同的范围而相互碰撞

0

此字符串资源具有相同的名称作为元素ID:edit_message

在这里,字符串资源具有名称作为edit_message和EDITTEXT也具有名称edit_message

引用资源总是由资源型

作用域这意味着,如果你正在做R.id.edit_message那么它将范围的EDITTEXTedit_text。因为这指的是id类型。

如果你这样做R.string.edit_text,它将范围的字符串edit_text类型,因为这是指一个字符串类型。

因此有人说,引用资源总是由资源型

0

作用域这意味着,你的ID和串都具有相同的name.But都具有两种不同的范围。 @id将寻找R.id.edit_message即id类,而@string将寻找R.string.edit_message

所以不要担心一切都很好。