在Android的碎片自定义属性 [英] Custom attributes in Android fragments

查看:102
本文介绍了在Android的碎片自定义属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想定义使用XML在Android的片段自定义属性(不使用捆绑的附加参数),如声明-设置样式的自定义控件。但也有没有构造与AttrSet参数,因此这可能吗?我可以覆盖公共无效onInflate(android.app.Activity活动,android.util.AttributeSet ATTRS,android.os.Bundle savedInstanceState),以获取属性的支持?

I'd like to define custom attributes in Android fragment using XML (without using bundle additional parameters) like declare-styleable in custom controls. But there are no constructors with AttrSet parameters, so is it possible? Can i just override public void onInflate(android.app.Activity activity, android.util.AttributeSet attrs, android.os.Bundle savedInstanceState) in order to get attributes support?

推荐答案

有一个演示,展示了如何做到这一点在Android开发者网站:

There is a demo that shows how to do this on the Android developers site:

<一个href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/index.html" rel="nofollow">http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/index.html

您想看看片段参数。

这篇关于在Android的碎片自定义属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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