Can't Call Setformat24hour Of A Textclock In A Widget
I'm trying to dynamically update the format24Hour of my Widget's TextClock. To do so I'm using RemoteViews like so: RemoteViews views = new RemoteViews(context.getPackageName(), R.
Solution 1:
Thanks to njzk2 I found the solution. It was a rather stupid problem.
I need to call RemoteViews#setCharSequence
instead of setString and then everything works fine!
Solution 2:
I know this question has been asked months ago, but your own is answer actually wrong I think.
As stated in the API guides, the only classes allowed on an appwidget are:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
ViewFlipper
ListView
GridView
StackView
AdapterViewFlipper
Therefore, you need an alarmManager that updates the widget each second, minute or hour when the screen is on, depending on what you want.
When updating the widget you must then change the text of a textview to the actual time. You can format this time as follows:
RemoteViewsviews=newRemoteViews(context.getPackageName(), viewID);
Calendarc= Calendar.getInstance();
SimpleDateFormattimeFormat24=newSimpleDateFormat("kk:mm");
Stringtime24= timeFormat24.format(c.getTime());
views.setTextViewText(R.id.textClock, time24);
Post a Comment for "Can't Call Setformat24hour Of A Textclock In A Widget"