在 Android 中创建海关控件

发布于 2024-10-09 07:05:56 字数 142 浏览 0 评论 0原文

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

<MyButton .... />

我想在资源 XML 中的某个位置定义 MyButton

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

<MyButton .... />

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里梦着梦中梦 2024-10-16 07:05:56

创建您自己的 View 子类(例如,com.ofirbit.MyButton),然后在您的布局中引用它(例如,)。 这是一个 Android 库项目和演示子项目,展示了自定义 ColorMixer 的实现 小部件及其在应用程序中的使用。有关如何实现其中一项的详细信息,请参阅一些 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文