當前位置: 首頁>>代碼示例>>Java>>正文


Java RemoteViews.setImageViewResource方法代碼示例

本文整理匯總了Java中android.widget.RemoteViews.setImageViewResource方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.setImageViewResource方法的具體用法?Java RemoteViews.setImageViewResource怎麽用?Java RemoteViews.setImageViewResource使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.RemoteViews的用法示例。


在下文中一共展示了RemoteViews.setImageViewResource方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: defaultAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(Context context, int[] appWidgetIds) {
    final Resources res = context.getResources();
    final RemoteViews views = new RemoteViews(context.getPackageName(),
            R.layout.album_appwidget4x2);

    views.setViewVisibility(R.id.albumname, View.GONE);
    views.setViewVisibility(R.id.trackname, View.GONE);
    views.setTextViewText(R.id.artistname,
            res.getText(R.string.widget_initial_text));
    views.setImageViewResource(R.id.albumart,
            R.drawable.albumart_mp_unknown);

    linkButtons(context, views);
    pushUpdate(context, appWidgetIds, views);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:20,代碼來源:MediaAppWidgetProvider4x2.java

示例2: defaultAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(Context context, int[] appWidgetIds) {

    final Resources res = context.getResources();
    final RemoteViews views = new RemoteViews(context.getPackageName(),
            R.layout.album_appwidget4x1_light);

    views.setViewVisibility(R.id.title, View.GONE);
    views.setTextViewText(R.id.artist,
            res.getText(R.string.widget_initial_text));
    views.setImageViewResource(R.id.albumart,
            R.drawable.albumart_mp_unknown);

    linkButtons(context, views);
    pushUpdate(context, appWidgetIds, views);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:20,代碼來源:MediaAppWidgetProvider4x1_Light.java

示例3: initWidgetViews

import android.widget.RemoteViews; //導入方法依賴的package包/類
public static void initWidgetViews(Context context, RemoteViews views, PingWidgetData data) {
    views.setTextViewText(R.id.widget_host, data.getAddress());
    views.setImageViewResource(R.id.widget_start_pause, android.R.drawable.ic_media_play);
    views.setInt(R.id.widget_layout_container_top, "setBackgroundResource", data.getTheme().getDrawableBackgroundContainerTop(data.getWidgetLayoutType()));
    views.setInt(R.id.widget_layout_container, "setBackgroundResource", data.getTheme().getDrawableBackgroundContainer(data.getWidgetLayoutType(), data.useDarkTheme()));

    views.setTextColor(R.id.widget_press_start, ContextCompat.getColor(context, (data.useDarkTheme() ? R.color.text_white : R.color.text_dark_gray)));
    views.setTextColor(R.id.widget_avg_ping, ContextCompat.getColor(context, (data.useDarkTheme() ? R.color.text_white : R.color.text_dark_gray)));
    views.setTextColor(R.id.widget_last_ping, ContextCompat.getColor(context, (data.useDarkTheme() ? R.color.text_white : R.color.text_dark_gray)));
    views.setTextColor(R.id.widget_max_min_ping, ContextCompat.getColor(context, (data.useDarkTheme() ? R.color.text_white : R.color.text_dark_gray)));
    views.setTextColor(R.id.widget_uptime_ping, ContextCompat.getColor(context, (data.useDarkTheme() ? R.color.text_white : R.color.text_dark_gray)));

    views.setViewVisibility(R.id.widget_loading, View.GONE);

    //Never pinged?
    if(data.getPingTimes().size() == 0) {
        views.setViewVisibility(R.id.widget_press_start, View.VISIBLE);
        views.setImageViewResource(R.id.widget_start_pause, android.R.drawable.ic_media_play);
    } else {
        RemoteViewsUtil.redrawWidget(context, views, data.getPingTimes(), data.getMaxPings().getValue(), data.getTheme().getChartColor(), data.showChartLines());
        views.setViewVisibility(R.id.widget_press_start, View.GONE);
        updatePlayPause(views, data.isRunning());
    }
}
 
開發者ID:abicelis,項目名稱:PingWidget,代碼行數:25,代碼來源:RemoteViewsUtil.java

示例4: defaultAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(Context context, int[] appWidgetIds) {
    final Resources res = context.getResources();
    final RemoteViews views = new RemoteViews(context.getPackageName(),
            R.layout.album_appwidget4x4);

    views.setViewVisibility(R.id.albumname, View.GONE);
    views.setTextViewText(R.id.trackname,
            res.getText(R.string.widget_initial_text));
    views.setImageViewResource(R.id.albumart,
            R.drawable.albumart_mp_unknown);

    linkButtons(context, views);
    pushUpdate(context, appWidgetIds, views);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:19,代碼來源:MediaAppWidgetProvider4x4.java

示例5: defaultAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
private void defaultAppWidget(Context context, int[] appWidgetIds) {
    final Resources res = context.getResources();
    final RemoteViews views = new RemoteViews(context.getPackageName(),
            R.layout.album_appwidget4x4_light);

    views.setViewVisibility(R.id.albumname, View.GONE);
    views.setTextViewText(R.id.trackname,
            res.getText(R.string.widget_initial_text));
    views.setImageViewResource(R.id.albumart,
            R.drawable.albumart_mp_unknown);

    linkButtons(context, views);
    pushUpdate(context, appWidgetIds, views);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:19,代碼來源:MediaAppWidgetProvider4x4_Light.java

示例6: getViewAt

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews remoteViews = new RemoteViews(mContext.getPackageName(), R.layout.queue_widget_listview_layout);
    if (position <= getCount()) {

        String songTitle = songs.get(position)._title;

        ImageSize imageSize = new ImageSize(75, 75);

        long songDurationInMillis = 0;
        try {
            songDurationInMillis = songs.get(position)._duration;
        } catch (Exception e) {
        }

        remoteViews.setTextViewText(R.id.listViewSubText, songTitle);
        remoteViews.setTextViewText(R.id.listViewRightSubText, MusicUtils.convertMillisToMinsSecs(songDurationInMillis));


        Bitmap bitmap = ImageLoader.getInstance().loadImageSync(String.valueOf(MusicUtils.getAlbumArtUri(mApp.getService().getSongList().get(position)._albumId)), imageSize);
        if (bitmap != null) {
            remoteViews.setImageViewBitmap(R.id.listViewLeftIcon, bitmap);
        } else {
            remoteViews.setImageViewResource(R.id.listViewLeftIcon, R.mipmap.ic_launcher);
        }

    }


  /* This intent latches itself onto the pendingIntentTemplate from
 * LargeWidgetProvider.java and adds the extra "INDEX" argument to it. */
    Intent fillInIntent = new Intent();
    fillInIntent.putExtra("INDEX", position);
    remoteViews.setOnClickFillInIntent(R.id.listViewParent, fillInIntent);

    return remoteViews;
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:38,代碼來源:QueueWidgetService.java

示例7: defaultAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
 * Initialize given widgets to default state, where we launch Music on
 * default click and hide actions if service not running.
 */
protected void defaultAppWidget(final Context context, final int[] appWidgetIds) {
    final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), R.layout.app_widget_big);

    appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
    appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art);
    appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));
    appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getPrimaryTextColor(context, false)), 1f));

    linkButtons(context, appWidgetView);
    pushUpdate(context, appWidgetIds, appWidgetView);
}
 
開發者ID:h4h13,項目名稱:RetroMusicPlayer,代碼行數:17,代碼來源:AppWidgetBig.java

示例8: setUpRemoteView

import android.widget.RemoteViews; //導入方法依賴的package包/類
private void setUpRemoteView(RemoteViews remoteView) {
    remoteView.setImageViewResource(R.id.image_view_close, R.drawable.ic_remote_view_close);
    remoteView.setImageViewResource(R.id.image_view_play_last, R.drawable.ic_remote_view_play_last);
    remoteView.setImageViewResource(R.id.image_view_play_next, R.drawable.ic_remote_view_play_next);

    remoteView.setOnClickPendingIntent(R.id.button_close, getPendingIntent(ACTION_STOP_SERVICE));
    remoteView.setOnClickPendingIntent(R.id.button_play_last, getPendingIntent(ACTION_PLAY_LAST));
    remoteView.setOnClickPendingIntent(R.id.button_play_next, getPendingIntent(ACTION_PLAY_NEXT));
    remoteView.setOnClickPendingIntent(R.id.button_play_toggle, getPendingIntent(ACTION_PLAY_TOGGLE));
}
 
開發者ID:xxczaki,項目名稱:music-player,代碼行數:11,代碼來源:PlaybackService.java

示例9: updateNotification

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public Notification updateNotification(Context c) {
    Notification n = mNotification;

    n.icon = mIcon;

    n.flags |= Notification.FLAG_ONGOING_EVENT;

    if (android.os.Build.VERSION.SDK_INT > 10) {
        n.flags |= Notification.FLAG_ONLY_ALERT_ONCE; // only matters for
                                                      // Honeycomb
    }

    // Build the RemoteView object
    RemoteViews expandedView = new RemoteViews(
            c.getPackageName(),
            R.layout.status_bar_ongoing_event_progress_bar);

    expandedView.setTextViewText(R.id.title, mTitle);
    // look at strings
    expandedView.setViewVisibility(R.id.description, View.VISIBLE);
    expandedView.setTextViewText(R.id.description,
            Helpers.getDownloadProgressString(mCurrentBytes, mTotalBytes));
    expandedView.setViewVisibility(R.id.progress_bar_frame, View.VISIBLE);
    expandedView.setProgressBar(R.id.progress_bar,
            (int) (mTotalBytes >> 8),
            (int) (mCurrentBytes >> 8),
            mTotalBytes <= 0);
    expandedView.setViewVisibility(R.id.time_remaining, View.VISIBLE);
    expandedView.setTextViewText(
            R.id.time_remaining,
            c.getString(R.string.time_remaining_notification,
                    Helpers.getTimeRemaining(mTimeRemaining)));
    expandedView.setTextViewText(R.id.progress_text,
            Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
    expandedView.setImageViewResource(R.id.appIcon, mIcon);
    n.contentView = expandedView;
    n.contentIntent = mPendingIntent;
    return n;
}
 
開發者ID:SlotNSlot,項目名稱:SlotNSlot_Android,代碼行數:41,代碼來源:V3CustomNotification.java

示例10: updateAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {
    CharSequence widgetText = context.getString(R.string.appwidget_text);
    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.days_widget);
    views.setTextViewText(R.id.appwidget_text1, widgetText);
    views.setTextViewText(R.id.appwidget_title, widgetText);
    views.setTextViewText(R.id.appwidget_check, widgetText);
    views.setTextViewText(R.id.appwidget_days, widgetText);
    views.setTextViewText(R.id.remind_text, widgetText);
    views.setImageViewResource(R.id.imageView, R.mipmap.logo);
    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
開發者ID:613-sysu,項目名稱:Days,代碼行數:15,代碼來源:DaysWidget.java

示例11: updateAppWidget

import android.widget.RemoteViews; //導入方法依賴的package包/類
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    CharSequence widgetText = context.getString(R.string.appwidget_text);
    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
    views.setImageViewResource(R.id.imageview, R.mipmap.btn_img_delete);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
開發者ID:wuhighway,項目名稱:DailyStudy,代碼行數:12,代碼來源:NewAppWidget.java

示例12: onReceive

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public void onReceive(Context context, Intent intent) {
    super.onReceive(context, intent);

    if (TOGGLE_CLICKED.equals(intent.getAction())) {
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context);
        RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.service_toggle_widget);
        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
        if (NLService.isEnabled()) {
            preferences.edit().putBoolean(context.getString(R.string.notification_listener_service_state_key), false).apply();
            NLService.setEnabled(false);
            views.setImageViewResource(R.id.widgetToggleButton, R.drawable.ic_speaker_notes_off_white_48dp);
            views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_red);
            views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_off_text));
            views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.red));
        } else {
            preferences.edit().putBoolean(context.getString(R.string.notification_listener_service_state_key), true).apply();
            NLService.setEnabled(true);
            views.setImageViewResource(R.id.widgetToggleButton,R.drawable.ic_speaker_notes_white_48dp);
            views.setInt(R.id.widgetToggleButton, "setBackgroundResource", R.drawable.round_rectangle_green);
            views.setTextViewText(R.id.widgetToggleText, context.getString(R.string.widget_on_text));
            views.setTextColor(R.id.widgetToggleText, ContextCompat.getColor(context, R.color.green));
        }

        views.setOnClickPendingIntent(
                R.id.widgetToggleButton,
                getPendingSelfIntent(context, 0, TOGGLE_CLICKED));

        ComponentName componentName = new ComponentName(context, ServiceToggle.class);
        appWidgetManager.updateAppWidget(componentName, views);
    }
}
 
開發者ID:abhijitvalluri,項目名稱:fitnotifications,代碼行數:33,代碼來源:ServiceToggle.java

示例13: build

import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public Notification build() {

    if (android.os.Build.VERSION.SDK_INT > 10) {
        // only matters for Honeycomb
        setOnlyAlertOnce(true);
    }

    // Build the RemoteView object
    RemoteViews expandedView = new RemoteViews(
            mContext.getPackageName(),
            Helpers.getLayoutResource(mContext, "status_bar_ongoing_event_progress_bar"));

    expandedView.setTextViewText(Helpers.getIdResource(mContext, "title"), mContentTitle);
    // look at strings
    expandedView.setViewVisibility(Helpers.getIdResource(mContext, "description"), View.VISIBLE);
    expandedView.setTextViewText(Helpers.getIdResource(mContext, "description"),
            Helpers.getDownloadProgressString(this.mCurrentBytes, mTotalBytes));
    expandedView.setViewVisibility(Helpers.getIdResource(mContext, "progress_bar_frame"), View.VISIBLE);
    expandedView.setProgressBar(Helpers.getIdResource(mContext, "progress_bar"),
            (int) (mTotalBytes >> 8),
            (int) (mCurrentBytes >> 8),
            mTotalBytes <= 0);
    expandedView.setViewVisibility(Helpers.getIdResource(mContext, "time_remaining"), View.VISIBLE);
    expandedView.setTextViewText(
            Helpers.getIdResource(mContext, "time_remaining"),
            mContentInfo);
    expandedView.setTextViewText(Helpers.getIdResource(mContext, "progress_text"),
            Helpers.getDownloadProgressPercent(mCurrentBytes, mTotalBytes));
    expandedView.setImageViewResource(Helpers.getIdResource(mContext, "appIcon"), mIcon);

    Notification n = super.build();
    n.contentView = expandedView;
    return n;
}
 
開發者ID:snoozinsquatch,項目名稱:unity-obb-downloader,代碼行數:36,代碼來源:V4CustomNotificationBuilder.java

示例14: updatePlayPause

import android.widget.RemoteViews; //導入方法依賴的package包/類
public static void updatePlayPause(RemoteViews views, boolean isRunning) {
    views.setImageViewResource(R.id.widget_start_pause, (isRunning ? android.R.drawable.ic_media_pause : android.R.drawable.ic_media_play) );
}
 
開發者ID:abicelis,項目名稱:PingWidget,代碼行數:4,代碼來源:RemoteViewsUtil.java

示例15: show

import android.widget.RemoteViews; //導入方法依賴的package包/類
public int show(String title, @DrawableRes int logo, int progress) {
    if (clickActivity != null) {
        Intent intent = new Intent(mContext, clickActivity);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        //intent.setFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME);
        mBuilder.setContentIntent(PendingIntent.getActivity(mContext, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT));// 該通知要啟動的Intent
    }

    RemoteViews remoteViews;

    if (progress >= 100) {
        remoteViews = mFinishRemoteViews;

        File targetFile = new File(targetFilePath);
        if (targetFile.exists()) {

            L.e("準備安裝-> " + targetFile.getAbsolutePath());
            mBuilder.setContentIntent(PendingIntent.getActivity(mContext, requestCode,
                    IntentUtils.getInstallAppIntent(targetFile), PendingIntent.FLAG_CANCEL_CURRENT));// 該通知要啟動的Intent
        } else {
            L.e("需要安裝的文件不存在-> " + targetFile.getAbsolutePath());
        }

        mBuilder.setOngoing(false);
    } else {
        mProgressRemoteViews.setProgressBar(R.id.progressBar, 100, progress, false);
        remoteViews = mProgressRemoteViews;

        mBuilder.setOngoing(true);
    }

    remoteViews.setImageViewResource(R.id.image_view, logo);
    remoteViews.setTextViewText(R.id.text_view, title);

    mBuilder.setSmallIcon(logo);// 設置頂部狀態欄的小圖標, 必須設置.
    mBuilder.setContent(remoteViews);
    mBuilder.setWhen(System.currentTimeMillis());
    mNotificationManager.notify(this.getClass().getSimpleName(), NOTIFICATION_ID, mBuilder.build());

    return NOTIFICATION_ID;
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:43,代碼來源:ProgressNotify.java


注:本文中的android.widget.RemoteViews.setImageViewResource方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。