I am trying to get a button to fade out when a particular event occurs, but the changes to the button are not instantaneous but instead wait for all the operations on the button performed to complete.Is there any (hopefully, simple) way to show the changes to the user as they occur?
CODE:
featuredimage.setBackgroundDrawable(getResources().getDrawable(R.drawable.featuredimage_cc_movement1));
for (int alpha = 0; alpha < 255; alpha+=10) {
//Thread.sleep(1);
featuredimage.setAlpha(alpha);
featuredinfo.setAlpha(alpha);
}
featuredinfo.setText(Html.fromHtml("<center><big><b>FEATURED " + catagory + "</b></big></center><br>"
+ getFeatured().getMediumString()));
featuredimage.setBackgroundDrawable(getResources().getDrawable(R.drawable.featuredimage_gradient));
for (int alpha = 255; alpha > 0; alpha--) {
//Thread.sleep(1);
featuredimage.setAlpha(alpha);
featuredinfo.setAlpha(alpha);
}
The best solution is use AsyncTask found here.