安卓自定义控件
发布日期:2021-06-30 18:39:19 浏览次数:2 分类:技术文章

本文共 565 字,大约阅读时间需要 1 分钟。

自定义属性
1,自定义命名空间     xmlns:lqr="http://schemas.android.com/apk/res/工程的包名"2,创建attrs.xml文件    
3,在自定义组件中使用自定义属性
获取自定义属性数据
public SettingCenterItemView(Context context, AttributeSet attrs) {        super(context, attrs);        initView();        initEvent();        String content = attrs.getAttributeValue("http://schemas.android.com/apk/res/工程包名", "自定义属性名");        String title = attrs.getAttributeValue("http://schemas.android.com/apk/res/工程包名", "title");        tv_title.setText(title);        contents = content.split("-");    }

转载地址:https://linqiarui.blog.csdn.net/article/details/51154597 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:数据分页代码总结
下一篇:播放音乐提示音

发表评论

最新留言

路过按个爪印,很不错,赞一个!
[***.219.124.196]2024年04月23日 20时19分44秒