My widget consists of two relative layouts. I made both layouts clickable. The following is the layout id:
android:id="@+id/upper_layout" android:id="@+id/bottom_layout"
Now I need that if the user clicks on upper_layout, bottom_layout should be invisible.
Here is what I have tried so far, but it does not work. Can you check what I am doing wrong? Or perhaps suggest other ways to achieve this.
The code:
public class BobsWidget extends AppWidgetProvider { public static String ACTION_WIDGET_RECEIVER = "Clicked"; @Override public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) { RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.main); Intent active = new Intent(context, BobsWidget.class); active.setAction(ACTION_WIDGET_RECEIVER); PendingIntent actionPendingIntent = PendingIntent.getBroadcast(context, 0, active, 0); remoteViews.setOnClickPendingIntent(R.id.upper_layout, actionPendingIntent); appWidgetManager.updateAppWidget(appWidgetIds, remoteViews); } @Override public void onReceive(Context context, Intent intent) {
curiousguy
source share