Unexpected Cast To Appcompatbutton: Layout Tag Was Button
From AppCompatButton reference page: This will automatically be used when you use Button in your layouts. You should only need to manually use this class when writing custom views
Solution 1:
It looks like a bug in the IDE type checking - Button is direct ancestor of AppCompatButton, so casting to AppCompatButton should be okay. I believe you can safely call it like this:
Buttonbutton= (Button) findViewById(R.id.normalButton);
((AppCompatButton)button).setSupportBackgroundTintList(ColorStateList.valueOf(tintColor));
or better
((TintableBackgroundView)button).setSupportBackgroundTintList(ColorStateList.valueOf(tintColor));
If you use Butterknife, everything works as expected without any warning:
@Bind(R.id.normalButton)
AppCompatButton button;
Post a Comment for "Unexpected Cast To Appcompatbutton: Layout Tag Was Button"