Customized GUI components for Android in eclipse

大憨熊 提交于 2019-12-11 05:49:13

问题


You know how in eclipse you can edit the XML file using the built-in eclipse GUI for adding GUI components? I'm looking to create my own component that I can add so I can drag and drop like the rest of the components. I've looked for a tutorial to no avail and couldn't find anything. Does anyone know how to do this?

Mind you I am using Java.


回答1:


You can create custom layout or component by creating a class that extends ViewGroup or the component (Ex: Button) that you want to create.

This will display your custom component under "Custom and Library Views" tab in graphical layout view of the xml.




回答2:


The newer versions of the android developer tools (ADT) supports custom views in the layout editor. I believe you need just make sure that your custom view has the constructor that takes attributes as an argument. Check out this video from Google IO 2011 which highlights some of the additions from the (what is now) 5 updates ago: http://www.youtube.com/watch?v=Oq05KqjXTvs



来源:https://stackoverflow.com/questions/8829959/customized-gui-components-for-android-in-eclipse

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!