创建海关在Android的控制 [英] Creating customs controls in Android

查看:79
本文介绍了创建海关在Android的控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android应用程序来创建自己的自定义控制,以这种方式使用它们:
在XML文件中:

I want to create my own custom controls in Android application and use them in this way: In the XML file:

<MyButton .... />

我想在资源XML来定义用作MyButton一些地方

I would like to define MyButton some where in the resources XML

推荐答案

创建您自己的查看(例如, com.ofirbit.MyButton子),然后引用它在你的布局(例如,&LT; com.ofirbit.MyButton机器人:ID =.../&GT; )。 这里是一个Android库项目和示范子项目显示一个定制的实现 Col​​orMixer 部件及其在应用程序中使用。如何实现其中的一个细节可以在一些Android的图书​​的的 Android文档,或许在别处。

Create your own subclass of View (e.g., com.ofirbit.MyButton) and then reference it in your layouts (e.g., <com.ofirbit.MyButton android:id="..." />). Here is an Android library project and demonstration sub-project showing an implementation of a custom ColorMixer widget and its use in an application. The details of how to implement one of these can be found in some Android books, the Android documentation, and perhaps elsewhere.

这篇关于创建海关在Android的控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆