I want to change one of the visual elements of an android widget when the user clicks it. This is in the widget's xml
<ImageView
android:id="@+id/bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="false"
android:layout_marginLeft="20dp"
android:layout_marginTop="18dp"
android:src="@drawable/seal" />
I want to change the src based on an ID, so from the widget I plan to send the remoteView a click listener
Intent bgSwitch = new Intent(widgetContext, MainActivity.class);
bgSwitch.putExtra("jurisdiction", "bg");
PendingIntent bgIntent = PendingIntent.getActivity(widgetContext,
6, bgSwitch, PendingIntent.FLAG_UPDATE_CURRENT);
remoteView.setOnClickPendingIntent(R.id.bg, bgIntent);
and in a transparent activity (or in the widget itself) I want to somehow change the imageview
's source.
I don't want to just flip the visibility of a bunch of imageviews
.
how would this be achieved?
You can try this way:
And also don't forget to add action in your manifest file and also add permissions for that.