Android - 按名称获取可定制的值

时间:2014-05-06 13:10:48

标签: android declare-styleable

有没有办法按名称获得样式,例如,如果我有字符串" Text"是否有可能获得R.styleable.CustomView_Text值(按值表示我只是指R.styleable.CustomView数组中的索引而不是属性值)而没有反射?

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <declare-styleable name="CustomView">

        <attr name="Text" format="string" />

    </declare-styleable>

</resources>

1 个答案:

答案 0 :(得分:0)

使用Resources.getIdentifier方法,将defType参数设置为&#39; styleable&#39;。