相关疑难解决方法(0)

android中的可点击小部件

开发人员文档似乎在这里失败了.我可以毫不犹豫地创建一个静态小部件,我甚至可以创建一个类似于模拟时钟小部件的小部件来更新自己,但是,我不能在我的生活中弄清楚如何创建一个小部件来响应用户点击的时间它.以下是开发人员文档为小部件活动应包含的内容提供的最佳代码示例(唯一的其他提示是API演示,仅创建静态小部件):

public class ExampleAppWidgetProvider extends AppWidgetProvider {
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        final int N = appWidgetIds.length;

        // Perform this loop procedure for each App Widget that belongs to this provider
        for (int i=0; i<N; i++) {
            int appWidgetId = appWidgetIds[i];

            // Create an Intent to launch ExampleActivity
            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 …
Run Code Online (Sandbox Code Playgroud)

java android onclick android-widget

61
推荐指数
1
解决办法
5万
查看次数

标签 统计

android ×1

android-widget ×1

java ×1

onclick ×1