Programatically Changing One Edittext Color Changes Edittexts Color In Whole App Using Android 5
I have very strange problem in Android 5. If user inputs something wrong I want to set error to edittext and change it color to red, and when user starts typing something I want to
Solution 1:
The problem is that the background Drawable
is reused across many Views. To ensure the Drawable
is not shared between multiple Views you should use the mutate
method.
See: mutate()
Example code:
Drawablebackground= mainMenuButton.getBackground();
background.mutate();
background.setColorFilter(newPorterDuffColorFilter(getResources().getColor(R.color.light_green), PorterDuff.Mode.MULTIPLY));
mainMenuButton.setBackground(background);
Android 5.0 Lollipop: setColorFilter "leaks" onto other buttons
Solution 2:
Do Same for like spinner colour changes..
In Android Lollipop Version you have to implement code for kitkat version and lollipop version separately , please do this code for change background of spinner. its example of image background changes of images.
if (Build.VERSION.SDK_INT => Build.VERSION_CODES.KitKat)
{
//for Lollipop Vession// do on textChangeListner code
eText.setBackgroundDrawable(Color.RED);
}
else
{
// do on textChangeListner code
eText.setBackgroundResource(Color.RED);
}
i hope it helps you, if it is useful code for then please mark me .. Thanx.. :)
Post a Comment for "Programatically Changing One Edittext Color Changes Edittexts Color In Whole App Using Android 5"