How to get a string from attr with reference format type?

后端 未结 2 2021
孤城傲影
孤城傲影 2021-02-15 13:27

I have my custom attr.xml document in which I specified declare-styleable:




        
2条回答
  •  孤城傲影
    2021-02-15 13:47

    TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.EditTextValidateablePreference);
    int resID = array.getResourceId(R.styleable.EditTextValidateablePreference_errorMessage, R.string.default_text);
    

    And from this int, you can get the string by saying...

    getResources().getString(resID);
    

提交回复
热议问题