本文整理匯總了Java中android.widget.RemoteViews.setViewVisibility方法的典型用法代碼示例。如果您正苦於以下問題:Java RemoteViews.setViewVisibility方法的具體用法?Java RemoteViews.setViewVisibility怎麽用?Java RemoteViews.setViewVisibility使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setViewVisibility方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setClockAmPm
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static void setClockAmPm(Context context, RemoteViews widget) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
if (DateFormat.is24HourFormat(context)) {
widget.setViewVisibility(R.id.ampm_text, View.GONE);
} else {
widget.setViewVisibility(R.id.ampm_text, View.VISIBLE);
Calendar currentCalendar = Calendar.getInstance();
int hour = currentCalendar.get(Calendar.HOUR_OF_DAY);
if (hour < 12) {
widget.setTextViewText(R.id.ampm_text, context.getResources().getString(R.string.time_am_default));
} else {
widget.setTextViewText(R.id.ampm_text, context.getResources().getString(R.string.time_pm_default));
}
}
}
else{
widget.setViewVisibility(R.id.ampm_text, View.GONE);
}
}
示例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);
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: notificationChange
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public RemoteViews notificationChange(Notification notification, int notificationId, RemoteViews remoteViews) {
if (mImageNotification != null) {
remoteViews.setViewVisibility(R.id.notification_icon, View.VISIBLE);
Picasso.with(this).load(mImageNotification)
.into(remoteViews, R.id.notification_icon, notificationId, notification);
}
remoteViews.setViewVisibility(R.id.notification_title, View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_title, "Video de prueba");
remoteViews.setViewVisibility(R.id.notification_subtitle, View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_subtitle, "Video de prueba");
remoteViews.setViewVisibility(R.id.stop_icon, View.GONE);
remoteViews.setViewVisibility(R.id.play_icon, View.GONE);
remoteViews.setViewVisibility(R.id.pause_icon, View.GONE);
return remoteViews;
}
示例4: notificationChange
import android.widget.RemoteViews; //導入方法依賴的package包/類
@Override
public RemoteViews notificationChange(Notification notification, int notificationId, RemoteViews remoteViews) {
if (mImageNotification != null) {
remoteViews.setViewVisibility(R.id.notification_icon, View.VISIBLE);
Picasso.with(this).load(mImageNotification)
.into(remoteViews, R.id.notification_icon, notificationId, notification);
}
remoteViews.setViewVisibility(R.id.notification_title, View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_title, mTitle.getText().toString());
remoteViews.setViewVisibility(R.id.notification_subtitle, View.VISIBLE);
remoteViews.setTextViewText(R.id.notification_subtitle, mSubtitle.getText().toString());
if (!mStop.isChecked()) {
remoteViews.setViewVisibility(R.id.stop_icon, View.GONE);
}
if (!mPlayPause.isChecked()) {
remoteViews.setViewVisibility(R.id.play_icon, View.GONE);
remoteViews.setViewVisibility(R.id.pause_icon, View.GONE);
}
return remoteViews;
}
示例5: addWorkProfileBadge
import android.widget.RemoteViews; //導入方法依賴的package包/類
/**
* Shows the work profile badge if it is needed.
*/
private void addWorkProfileBadge(RemoteViews view) {
Resources resources = mContext.getResources();
DisplayMetrics metrics = resources.getDisplayMetrics();
int size = dpToPx(WORK_PROFILE_BADGE_SIZE_DP, metrics);
int[] colors = new int[size * size];
// Create an immutable bitmap, so that it can not be reused for painting a badge into it.
Bitmap bitmap = Bitmap.createBitmap(colors, size, size, Bitmap.Config.ARGB_8888);
Drawable inputDrawable = new BitmapDrawable(resources, bitmap);
Drawable outputDrawable = ApiCompatibilityUtils.getUserBadgedDrawableForDensity(
mContext, inputDrawable, null /* badgeLocation */, metrics.densityDpi);
// The input bitmap is immutable, so the output drawable will be a different instance from
// the input drawable if the work profile badge was applied.
if (inputDrawable != outputDrawable && outputDrawable instanceof BitmapDrawable) {
view.setImageViewBitmap(
R.id.work_profile_badge, ((BitmapDrawable) outputDrawable).getBitmap());
view.setViewVisibility(R.id.work_profile_badge, View.VISIBLE);
}
}
示例6: 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_appwidget2x1);
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist,
res.getText(R.string.widget_initial_text));
linkButtons(context, views);
pushUpdate(context, appWidgetIds, views);
}
示例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_card);
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
appWidgetView.setViewVisibility(R.id.image, View.INVISIBLE);
appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, true)), 1f));
linkButtons(context, appWidgetView);
pushUpdate(context, appWidgetIds, appWidgetView);
}
示例8: 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_appwidget2x1_light);
views.setViewVisibility(R.id.title, View.GONE);
views.setTextViewText(R.id.artist,
res.getText(R.string.widget_initial_text));
linkButtons(context, views);
pushUpdate(context, appWidgetIds, views);
}
示例9: 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(final Context context, final int[] appWidgetIds) {
final RemoteViews appWidgetView = new RemoteViews(context.getPackageName(), R.layout.app_widget_classic);
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
appWidgetView.setViewVisibility(R.id.image, View.INVISIBLE);
appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));
appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(context, R.drawable.ic_play_arrow_white_24dp, MaterialValueHelper.getSecondaryTextColor(context, false)), 1f));
linkButtons(context, appWidgetView);
pushUpdate(context, appWidgetIds, appWidgetView);
}
示例10: applyStandardTemplate
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static RemoteViews applyStandardTemplate(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, int resId, boolean fitIn1U) {
RemoteViews contentView = new RemoteViews(context.getPackageName(), resId);
boolean showLine3 = false;
boolean showLine2 = false;
if (largeIcon == null || VERSION.SDK_INT < 16) {
contentView.setViewVisibility(R.id.icon, 8);
} else {
contentView.setViewVisibility(R.id.icon, 0);
contentView.setImageViewBitmap(R.id.icon, largeIcon);
}
if (contentTitle != null) {
contentView.setTextViewText(R.id.title, contentTitle);
}
if (contentText != null) {
contentView.setTextViewText(R.id.text, contentText);
showLine3 = true;
}
if (contentInfo != null) {
contentView.setTextViewText(R.id.info, contentInfo);
contentView.setViewVisibility(R.id.info, 0);
showLine3 = true;
} else if (number > 0) {
if (number > context.getResources().getInteger(R.integer.status_bar_notification_info_maxnum)) {
contentView.setTextViewText(R.id.info, context.getResources().getString(R.string.status_bar_notification_info_overflow));
} else {
contentView.setTextViewText(R.id.info, NumberFormat.getIntegerInstance().format((long) number));
}
contentView.setViewVisibility(R.id.info, 0);
showLine3 = true;
} else {
contentView.setViewVisibility(R.id.info, 8);
}
if (subText != null && VERSION.SDK_INT >= 16) {
contentView.setTextViewText(R.id.text, subText);
if (contentText != null) {
contentView.setTextViewText(R.id.text2, contentText);
contentView.setViewVisibility(R.id.text2, 0);
showLine2 = true;
} else {
contentView.setViewVisibility(R.id.text2, 8);
}
}
if (showLine2 && VERSION.SDK_INT >= 16) {
if (fitIn1U) {
contentView.setTextViewTextSize(R.id.text, 0, (float) context.getResources().getDimensionPixelSize(R.dimen.notification_subtext_size));
}
contentView.setViewPadding(R.id.line1, 0, 0, 0, 0);
}
if (when != 0) {
if (useChronometer) {
contentView.setViewVisibility(R.id.chronometer, 0);
contentView.setLong(R.id.chronometer, "setBase", (SystemClock.elapsedRealtime() - System.currentTimeMillis()) + when);
contentView.setBoolean(R.id.chronometer, "setStarted", true);
} else {
contentView.setViewVisibility(R.id.time, 0);
contentView.setLong(R.id.time, "setTime", when);
}
}
contentView.setViewVisibility(R.id.line3, showLine3 ? 0 : 8);
return contentView;
}
示例11: generateContentView
import android.widget.RemoteViews; //導入方法依賴的package包/類
private static <T extends Action> RemoteViews generateContentView(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, List<T> actions, int[] actionsToShowInCompact, boolean showCancelButton, PendingIntent cancelButtonIntent) {
int N;
RemoteViews view = applyStandardTemplate(context, contentTitle, contentText, contentInfo, number, largeIcon, subText, useChronometer, when, R.layout.notification_template_media, true);
int numActions = actions.size();
if (actionsToShowInCompact == null) {
N = 0;
} else {
N = Math.min(actionsToShowInCompact.length, 3);
}
view.removeAllViews(R.id.media_actions);
if (N > 0) {
for (int i = 0; i < N; i++) {
if (i >= numActions) {
throw new IllegalArgumentException(String.format("setShowActionsInCompactView: action %d out of bounds (max %d)", new Object[]{Integer.valueOf(i), Integer.valueOf(numActions - 1)}));
}
Context context2 = context;
RemoteViews button = generateMediaActionButton(context2, (Action) actions.get(actionsToShowInCompact[i]));
view.addView(R.id.media_actions, button);
}
}
if (showCancelButton) {
view.setViewVisibility(R.id.end_padder, 8);
view.setViewVisibility(R.id.cancel_action, 0);
view.setOnClickPendingIntent(R.id.cancel_action, cancelButtonIntent);
view.setInt(R.id.cancel_action, "setAlpha", context.getResources().getInteger(R.integer.cancel_button_image_alpha));
} else {
view.setViewVisibility(R.id.end_padder, 0);
view.setViewVisibility(R.id.cancel_action, 8);
}
return view;
}
示例12: 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);
}
示例13: getNotificationViews
import android.widget.RemoteViews; //導入方法依賴的package包/類
public static RemoteViews getNotificationViews(final Track track, final Context context, boolean isPlaying) {
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.notification);
views.setTextViewText(R.id.notifTitle, track.getTitle());
views.setTextViewText(R.id.notifArtist, track.getArtist());
Bitmap cover = MediaUtils.getArtworkQuick(context, track, 180, 180);
if (cover != null)
views.setImageViewBitmap(R.id.notifAlbum, cover);
else
views.setImageViewResource(R.id.notifAlbum, R.drawable.ic_launcher);
if (Build.VERSION.SDK_INT < 11) {
views.setViewVisibility(R.id.action_prev, View.GONE);
views.setViewVisibility(R.id.action_play, View.GONE);
views.setViewVisibility(R.id.action_next, View.GONE);
}
views.setImageViewResource(R.id.action_play, isPlaying ? R.drawable.selector_pause_button : R.drawable.selector_play_button);
ComponentName componentName = new ComponentName(context, PlayerService.class);
Intent intentPlay = new Intent(PlayerService.PLAY);
intentPlay.setComponent(componentName);
views.setOnClickPendingIntent(R.id.action_play, PendingIntent.getService(context, 0, intentPlay, 0));
Intent intentNext = new Intent(PlayerService.NEXT);
intentNext.setComponent(componentName);
views.setOnClickPendingIntent(R.id.action_next, PendingIntent.getService(context, 0, intentNext, 0));
Intent intentPrevious = new Intent(PlayerService.PREV);
intentPrevious.setComponent(componentName);
views.setOnClickPendingIntent(R.id.action_prev, PendingIntent.getService(context, 0, intentPrevious, 0));
return views;
}
示例14: 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);
}
示例15: 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;
}