Reputation: 11
I've been trying to add configuration screen for my widget and I'm having problems getting it to work. The configuration screen comes up fine when I first add the widget to my home screen, but it's supposed to also come up when the user clicks on the widget. That's the part that is not working.
Here's the onUpdate code:
Intent intent = new Intent(context, WidgetConfiguration.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setOnClickPendingIntent(R.id.temperatureWidget, pendingIntent);
Here's the xml for the widget layout (widget.xml):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/frame"
android:clickable="true"
android:focusable="true"
android:id="@+id/temperatureWidget">
<ImageView
android:layout_marginTop="15px"
android:layout_marginLeft="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/img_thermometer"/>
<TextView
android:id="@+id/TextView01"
android:layout_marginTop="35px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="12pt"
android:textColor="@color/black"
android:text=" Temp: "/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35px"
android:textSize="12pt"
android:textColor="@color/black"
android:id="@+id/txtTemperature"/>
</LinearLayout>
When I click on the widget, nothing happens. Any ideas?
Upvotes: 0
Views: 4191
Reputation: 1067
You need to add a line as given in appwidget docs
appWidgetManager.updateAppWidget(appWidgetId, views);
Upvotes: 2
Reputation: 2548
I have a feeling it is something in your xml layout for the widget. Are you sure that R.id.temperatureWidget
is clickable? Is that a button or is that what your actually layout named?
Upvotes: 0