每這裏的問題中,Android的 「工具」 命名空間佈局的XML文檔
What's "tools:context" in Android layout files?
'工具' 命名空間引用(的xmlns:工具= 「http://schemas.android.com/tools」 )最近已經開始出現在我的佈局中,我想知道更多。原帖僅描述的「工具:上下文」屬性,但我也注意到的使用「工具:列表項」屬性出現的時候我已經指定了一個列表視圖預覽佈局項目,即
<ListView
android:id="@+id/lvCustomer"
tools:listitem="@layout/customer_list_item" >
</ListView>
是否有更多元素?
讓我看到這個'工具'命名空間的是我希望在eclipse中使用佈局設計器時能夠具有'僅預覽'文本(即在TextView或EditText中)。
目前,我安排我的佈局時分配'文本'或'提示'屬性預覽文本...但我總是必須記住從代碼內清除預覽值。
理想的情況下,而不是
<string name="preview_customer_name">Billy Bob's Roadhouse Pub</string>
...
<TextView
android:id="@+id/tvCustomerName"
android:text="@string/preview_customer_name"
</TextView>
有一個是這樣的:
<TextView
android:id="@+id/tvCustomerName"
tools:previewText="@string/preview_customer_name"
</TextView>
Thanks-
這可以使用自定義語言環境下的@string資源來完成嗎? – bjdodson 2012-08-08 17:58:34
@bjdodson - 這解決了我的問題,對我的'@ string/preview_text'功能非常有用。我剛剛創建了一個新的字符串資源,並選擇了一個不尋常的語言變體,並將所有的@ @ string/preview_text_blah'元素放在那裏。那麼我可以很容易地切換到預覽模式下的本地。謝謝您的幫助。 – dsp0549 2013-06-07 05:00:09