我写了一份可点击的植被。 我可以看到植被。 但是,我没有发现这种植被中的点击事件。 如果我点击植被,那么就应当采用收割方法。 但它没有被叫。 任何人都能够指导我可能是问题。
Source Code
import android.app.PendingIntent;
import android.appwidget.AppWidgetManager;
import android.appwidget.AppWidgetProvider;
import android.content.Context;
import android.content.Intent;
import android.widget.RemoteViews;
public class MyWidget extends AppWidgetProvider {
public static int IDs[];
Context context;
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
super.onReceive(context, intent);
System.out.println("...inside receive11....");
if (intent.getAction().equals("com.fedorvlasov.lazylist.NEXT_CLICK")) {
System.out.println("Back Button Clicked :::::::::::: ");
onUpdate(context, AppWidgetManager.getInstance(context), IDs);
// views = new RemoteViews(context.getPackageName(), R.layout.main);
}
if (intent.getAction().equals(
"com.fedorvlasov.lazylist.NEXT_CLICK_NEXT")) {
System.out.println("Onion Button Clicked Button:::::::::::: ");
onUpdate(context, AppWidgetManager.getInstance(context), IDs);
// views = new RemoteViews(context.getPackageName(), R.layout.main);
}
if (intent.getAction()
.equals("com.fedorvlasov.lazylist.TEXTVIEW_CLICK")) {
System.out.println("Next Button Clicked :::::::::::: ");
onUpdate(context, AppWidgetManager.getInstance(context), IDs);
}
System.out.println("...out to receive11....");
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds) {
// TODO Auto-generated method stub
super.onUpdate(context, appWidgetManager, appWidgetIds);
IDs = appWidgetIds;
this.context = context;
System.out.println("...inside update....");
RemoteViews remoteViews = new RemoteViews(context.getPackageName(),
R.layout.mywidget);
Intent buttonPrevious = new Intent(context, MyWidget.class);
buttonPrevious.setAction("com.fedorvlasov.lazylist.NEXT_CLICK");
PendingIntent pendingIntentButtonP = PendingIntent.getBroadcast(
context, 0, buttonPrevious, 0);
remoteViews.setOnClickPendingIntent(R.id.mywidget_left,
pendingIntentButtonP);
Intent buttonMiddle = new Intent(context, MyWidget.class);
buttonMiddle.setAction("com.fedorvlasov.lazylist.TEXTVIEW_CLICK");
PendingIntent pendingIntentButtonM = PendingIntent.getBroadcast(
context, 0, buttonMiddle, 0);
remoteViews.setOnClickPendingIntent(R.id.mywidget_middle,
pendingIntentButtonM);
Intent buttonNext = new Intent(context, MyWidget.class);
buttonNext.setAction("com.fedorvlasov.lazylist.NEXT_CLICK_NEXT");
PendingIntent pendingIntentButtonN = PendingIntent.getBroadcast(
context, 0, buttonNext, 0);
remoteViews.setOnClickPendingIntent(R.id.mywidget_right,
pendingIntentButtonN);
}
}
In Manifest file
<receiver android:name=".MyWidget" android:label="@string/app_name">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="com.fedorvlasov.lazylist.NEXT_CLICK" />
<action android:name="com.fedorvlasov.lazylist.NEXT_CLICK_NEXT" />
<action android:name="com.fedorvlasov.lazylist.TEXTVIEW_CLICK" />
</intent-filter>
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widget_info" android:process=":remote" />
</receiver>