1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| private CharSequence title; public CustomTextView(Context context) { super(context); } public CustomTextView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.test_attr); title = ta.getText(R.styleable.test_attr_test_text); ta.recycle(); } public CustomTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Override protected void onFinishInflate() { super.onFinishInflate(); setText(title); }
|