Example usage for android.widget RemoteViews setTextViewCompoundDrawablesRelative

List of usage examples for android.widget RemoteViews setTextViewCompoundDrawablesRelative

Introduction

In this page you can find the example usage for android.widget RemoteViews setTextViewCompoundDrawablesRelative.

Prototype

public void setTextViewCompoundDrawablesRelative(int viewId, Icon start, Icon top, Icon end, Icon bottom) 

Source Link

Document

Equivalent to calling TextView#setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable,Drawable,Drawable,Drawable) using the drawables yielded by Icon#loadDrawable(Context) .

Usage

From source file:com.android.deskclock.data.StopwatchModel.java

private static void setTextViewDrawable(RemoteViews rv, int viewId, int drawableId) {
    rv.setTextViewCompoundDrawablesRelative(viewId, drawableId, 0, 0, 0);
}

From source file:org.chromium.chrome.browser.notifications.CustomNotificationBuilder.java

@Override
public Notification build() {
    RemoteViews compactView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification);
    RemoteViews bigView = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_big);

    String time = DateFormat.getTimeFormat(mContext).format(new Date());
    for (RemoteViews view : new RemoteViews[] { compactView, bigView }) {
        view.setTextViewText(R.id.time, time);
        view.setTextViewText(R.id.title, mTitle);
        view.setTextViewText(R.id.body, mBody);
        view.setTextViewText(R.id.origin, mOrigin);
        view.setImageViewBitmap(R.id.icon, mLargeIcon);
    }/*from w  ww .j a va2 s.  co m*/

    if (!mActions.isEmpty()) {
        bigView.setViewVisibility(R.id.button_divider, View.VISIBLE);
        bigView.setViewVisibility(R.id.buttons, View.VISIBLE);
        for (Action action : mActions) {
            RemoteViews button = new RemoteViews(mContext.getPackageName(), R.layout.web_notification_button);
            button.setTextViewCompoundDrawablesRelative(R.id.button, action.getIcon(), 0, 0, 0);
            button.setTextViewText(R.id.button, action.getTitle());
            button.setOnClickPendingIntent(R.id.button, action.getActionIntent());
            bigView.addView(R.id.buttons, button);
        }
    }

    NotificationCompat.Builder builder = new NotificationCompat.Builder(mContext);
    builder.setTicker(mTickerText);
    builder.setSmallIcon(mSmallIconId);
    builder.setContentIntent(mContentIntent);
    builder.setDeleteIntent(mDeleteIntent);
    builder.setDefaults(mDefaults);
    builder.setVibrate(mVibratePattern);
    builder.setContent(compactView);

    Notification notification = builder.build();
    notification.bigContentView = bigView;
    return notification;
}