0

I have a custom Button view. Where I want to get the current text from attributes, modify it and show it.

public class GreenRoundedButton extends AppCompatButton {

public GreenRoundedButton(Context context, AttributeSet attrs) {
    super(context, attrs);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GreenRoundedButton);
    CharSequence t = a.getText(R.styleable.GreenRoundedButton_android_text);
    a.recycle();

    this.setText("something  else");
}

Currently, I'm able to get the android:text attribute (SO answer) but I cannot reassign to any other value.

Is there a different way to do this than setText()?

kike
  • 4,255
  • 5
  • 23
  • 41

0 Answers0