tags:

views:

7

answers:

0

Hi guys,

I'm developing an home screen widget with an ImageButton in it. When I click the button I try to change image, but the image is not refreshed. I think it's just a view refreshing problem. Do you know how to refresh the view? Thank you.

My code is this:

@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(ACTION_TOGGLE_WIDGET)) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.my_layout_widget);
views.setInt(R.id.my_image_button, "setImageResource", R.drawable.icon_red);
}
super.onReceive(context, intent);
}

I think what I'm looking for is a method like invalidate() that you can call on a view. How to ask android to refresh my widget?

Thank you again!