Cant change the android:background from my widget_main.xml
I have tryed
remoteviews.setInt(R.id.boton, "setBackgroundResource", R.drawable.toggle_on);
and
remoteviews.setImageViewResource(R.id.boton, R.drawable.toggle_on);
with no results.
Here is my widget_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<Button
android:id="@+id/boton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/toggle_off"/>
and my onReceive from my AppWidgetProvider:
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(WIDGET_BUTTON)) {
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.activity_main);
views.setInt(R.id.boton, "setBackgroundResource", R.drawable.toggle_on);