0
我正在創建一個用於學習目的的模擬時鐘小組件,並想知道如何進行設置佈局以更改時鐘撥號圖像。我已經完成了小部件,但我似乎無法獲得onclicklstener來調出設置佈局。更改時鐘撥號圖像
這是我有:
@Override
public void onDeleted(Context context, int[] appWidgetIds)
{super.onDeleted(context, appWidgetIds);
}
@Override
public void onDisabled(Context context) {
super.onDisabled(context);
}
@Override
public void onReceive(Context context, Intent intent)
{
String action = intent.getAction();
if (AppWidgetManager.ACTION_APPWIDGET_UPDATE.equals(action))
{
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
Intent AlarmClockIntent = new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER).setComponent(new ComponentName("com.android.alarmclock", "com.android.alarmclock.AlarmClock"));
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, AlarmClockIntent, 0);
views.setOnClickPendingIntent(R.id.Widget, pendingIntent);
AppWidgetManager.getInstance(context).updateAppWidget(intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS), views);
}
}
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
int[] appWidgetIds)
{
super.onUpdate(context, appWidgetManager, appWidgetIds);
RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.settings);
Intent launchActivity = new Intent(context,Widget.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context,0, launchActivity, 0);
updateViews.setOnClickPendingIntent(R.id.Widget, pendingIntent);
ComponentName myComponentName = new ComponentName(context, Settings.class);
AppWidgetManager manager = AppWidgetManager.getInstance(context);
manager.updateAppWidget(myComponentName, updateViews);
}
}
「不知道從哪裏開始」總是會讓你失望,你需要給我們更多的工作機會。 – djechlin
我已更新OP瞭解更多信息 –
是的,我已經刪除了我的downvote :) – djechlin