問題描述
我正在使用軟鍵盤示例開發一個動態鍵盤應用程序.我的應用程序更改布局.例如我有一個鍵盤(一鍵),然后我設置了應用程序,我可以使用鍵盤(一鍵).
I'm developing a dynamic keyboard application using soft keyboard sample. My application changes layout. For example I have a keyboard(has one key) then I set up the app and I can use keyboard(has one key).
我想在編譯后創建一個 XML 文件并在應用程序中使用這個文件(使用 xmlpullparser 或 xmlresourceparser 讀取 XML 文件).但是,鍵盤類需要 XML 的 id.如何創建 XML id?
I want to create an XML file after compilation and use this file in the application (reading XML file with xmlpullparser or xmlresourceparser). However, keyboard class needs XML's id. How do I create an XML id?
推薦答案
可以在 ids.xml
或任何自定義文件中定義,如 constants.xml
在你的 resvalues
文件夾.
It can be defined in ids.xml
or any custom file like constants.xml
inside your resvalues
folder.
例子:
<resources>
<item type="id" name="keyboard" />
</resources>
并且可以在如下代碼中訪問:
and can be accessed in the code as following:
R.id.keyboard
這篇關于android - 如何創建 xml 的 id?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!