How to retrieve XML attribute for custom control

前端 未结 2 1224
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-19 16:49

I\'ve created a combo box control with a edittext and spinner. I\'m trying to let the android:prompt attribute be passed onto the spinner, which means I need to catch it i

2条回答
  •  悲哀的现实
    2020-12-19 17:04

    1. Define a style in the xml. For ex :

    2. To get the value in the constructor use : TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ComboBox);

    Use the TypedArray get methods to get the particular attribute.

提交回复
热议问题