什么是AttributeSet中,我该如何使用呢? [英] What is AttributeSet and how can i use it?

查看:167
本文介绍了什么是AttributeSet中,我该如何使用呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是属性集中的在Android的?

What is AttributeSet in Android?

我如何使用它为我的自定义视图?

How can i use it for my custom view?

推荐答案

AttributeSet中的是一组在XML资源文件中指定的属性。你不应该在你的自定义视图做什么特别的。该视图(上下文的背景下,ATTRS的AttributeSet)被调用来初始化从布局文件的视图。就在这个构造函数添加到您的自定义视图。退房的<一个href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/LabelView.html">Custom查看比如在SDK中看到它。

AttributeSet is the set of properties specified in an xml resource file. You shouldn't have to do anything special in your custom view. The View(Context context, AttributeSet attrs) gets called to initialize a view from a layout file. Just add this constructor to your custom view. Check out the Custom View example in the SDK to see it used.

这篇关于什么是AttributeSet中,我该如何使用呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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