- String lastUpdate = new SimpleDateFormat("yyyy/MM/dd\n\nE\n\na hh:mm:ss").format(new Date());
- RemoteViews remoteView = new RemoteViews(getPackageName(),R.layout.main);
- remoteView.setTextViewText(R.id.now, lastUpdate);
-
- ComponentName thisWidget = new ComponentName(this,MyWidget.class);
- AppWidgetManager manager = AppWidgetManager.getInstance(this);
- manager.updateAppWidget(thisWidget,remoteView);
複製代碼 |