Tanks for your kindly support,JS. Now I put the onclickactions to a BoardcastReceiver,then bind the BoardcastReceiver to a intent.If I want to do some operations when click the button, I need to create a PendingIntent object to wrap the intent,and use RemoteViews.setOnClickPendingIntent(int buttonID, PendingIntent pi) to bind the button with the button actions.
final ComponentName receiverName = new ComponentName(context, MemoBroadcastReceiver.class); Intent deleteMemoIntent = new Intent( MemoBroadcastReceiver.DELETE_ACTION); deleteMemoIntent.setComponent(receiverName); Bundle deleteBundle = new Bundle(); deleteBundle.putInt("KEY_APPWIDGETID", appWidgetID); deleteBundle.putLong("KEY_PRIORITY", priority); deleteMemoIntent.putExtras(deleteBundle); PendingIntent deleteMemoPending = PendingIntent.getBroadcast(context, 0, deleteMemoIntent, PendingIntent.FLAG_CANCEL_CURRENT); views.setOnClickPendingIntent(R.id.delete, deleteMemoPending); Best Reagards, Clybe 2009/6/17 Jeff Sharkey <jshar...@android.com> > > > I don't know how to get the button object from appwidget(get the ture > > layout copy of home screen). > > You can't access the actually-inflated layout from your app because it > exists entirely in another process. > > > > I know the RemoteView offeres an interface > > RemoteView.setOnClickPendingIntent,but what I need is > > RemoteView.setOnClickListener(R.id.delete,OnClickListener) > > You can't setOnClickListener() directly, because the target View lives > in another process. If this were allowed, the other process would be > executing your code as itself, which is a security hole. > > > -- > Jeff Sharkey > jshar...@android.com > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---