Code example for RemoteViews

Methods: setTextViewText

0
    } 
 
    private void setContactName(RemoteViews views, Event event, int viewId) {
        SpannableString caption = new SpannableString(event.getDisplayName());
        addSpan(caption, event.getDaysToEvent());
        views.setTextViewText(viewId, caption);
    } 
 
    private void setContactDate(Context ctx, RemoteViews views, Event event, int viewId) {
        SpannableString caption = new SpannableString(event.getDisplayDate(ctx) + " (+" + event.getDaysToEvent() + ")");
        addSpan(caption, event.getDaysToEvent());
        views.setTextViewText(viewId, caption);
    } 
     
    private void addSpan(SpannableString caption, int daysToEvent) {
        if (daysToEvent < 6) {
            caption.setSpan(new StyleSpan(Typeface.BOLD), 0, caption.length(), 0);
        } 
 
        if (daysToEvent < 2) {
            caption.setSpan(new ForegroundColorSpan(Color.RED), 0, caption.length(), 0);