我正在android 2.2上开发一个应用程序。我的应用程序显示widget上的job count。当我点击这个小工具时,用户必须重定向到一个网站。
这里我们如何用TextView实现带有背景图片的控件的点击事件。
关于这一点,请帮助我。
发布于 2011-04-13 16:15:26
请查看以下教程
http://developer.android.com/guide/topics/appwidgets/index.html
AppWidgetProvider的onUpdate事件就是您要寻找的。上面的页面上有一个部分。基本上,您可以在AppWidgetProvider类中执行类似以下内容的操作。
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
/* loop through each widgets created by this provider and do the following */
Intent intent = new Intent(context, ExampleActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent, 0);
// Get the layout for the App Widget and attach an on-click listener to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.appwidget_provider_layout);
views.setOnClickPendingIntent(R.id.button, pendingIntent);
}https://stackoverflow.com/questions/5646041
复制相似问题