本文整理汇总了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);
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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;
}
示例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) );
}
示例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;
}