本文整理汇总了Java中android.widget.RemoteViews.setTextViewText方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setTextViewText方法的具体用法?Java RemoteViews.setTextViewText怎么用?Java RemoteViews.setTextViewText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setTextViewText方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateAppWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
int appWidgetId) {
CharSequence widgetText = HiAppWidgetConfigureActivity.loadTitlePref(context, appWidgetId);
int pos = HiAppWidgetConfigureActivity.loadPosPref(context, appWidgetId) % texts.length;
// Construct the RemoteViews object
int layoutId = pos == 3 ? R.layout.hi_app_widget_other : R.layout.hi_app_widget;
RemoteViews views = new RemoteViews(context.getPackageName(), layoutId);
views.setTextViewText(R.id.title, widgetText);
views.setTextViewText(R.id.appwidget_text, context.getString(texts[pos]));
views.setOnClickPendingIntent(R.id.back, getPendingIntent(context, appWidgetId, -1));
views.setOnClickPendingIntent(R.id.next, getPendingIntent(context, appWidgetId, +1));
// Instruct the widget manager to update the widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
示例2: 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;
}
示例3: notifyDownloadStart
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* 开始下载
*
* @param context
* @param title
* @param icon
*/
private void notifyDownloadStart(Context context, Request request)
{
RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.api_download_notification);
remoteViews.setProgressBar(R.id.noti_progressBar, PROGRESSBAR_MAX, 0, false);
remoteViews.setImageViewResource(R.id.noti_icon, R.drawable.notification_remote_icon);
remoteViews.setTextViewText(R.id.noti_file_name, request.mTitle);
String host = CommonUtils.getHost(request.mDownloadUrl);
if (CommonUtils.isWo2bHost(request.mDownloadUrl))
{
remoteViews.setTextViewText(R.id.noti_progressBarLeft, "www.wo2b.com");
}
else
{
remoteViews.setTextViewText(R.id.noti_progressBarLeft, host);
}
// 执行取消操作的PendingIntent, 向DownloadService发起取消下载的命令
Intent cancelIntent = new Intent();
cancelIntent.setClass(context, DownloadService.class);
cancelIntent.putExtra(DownloadService.EXTRA_EVENT_TYPE, DownloadService.EVENT_CANCEL);
cancelIntent.putExtra(DownloadService.EXTRA_DOWNLOAD_URL, request.mDownloadUrl);
PendingIntent cancelPendingIntent = PendingIntent.getService(context, 100, cancelIntent,
PendingIntent.FLAG_CANCEL_CURRENT);
remoteViews.setOnClickPendingIntent(R.id.noti_cancel, cancelPendingIntent);
// 消息信息设置
Notification notification = new Notification();
notification.tickerText = request.mTitle;
notification.icon = R.drawable.notification_icon;
notification.contentView = remoteViews;
// notification.flags = Notification.FLAG_AUTO_CANCEL;
notification.flags = Notification.FLAG_ONGOING_EVENT;
// 点击通知栏
Intent intent = new Intent();
intent.setAction("com.wo2b.download.AActivity");
// intent.setClass(context, Download.class);
notification.contentIntent = PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_CANCEL_CURRENT);
// 生成通知ID
int notificationId = new Random().nextInt(10000);
mNotificationManager.notify(notificationId, notification);
request.mNotification = notification;
request.mNotificationId = notificationId;
}
示例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: 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_light);
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);
}
示例6: createNotificationLayout
import android.widget.RemoteViews; //导入方法依赖的package包/类
public static RemoteViews createNotificationLayout(Context context, TrainStop stop) {
DateTimeFormatter df = DateTimeFormat.forPattern("HH:mm");
RemoteViews contentView = new RemoteViews(context.getPackageName(), R.layout.notif_h64);
contentView.setTextViewText(R.id.text_time1, df.print(stop.getDepartureTime()));
contentView.setTextViewText(R.id.text_delay1, String.valueOf(stop.getDepartureDelay().getStandardMinutes()));
contentView.setTextViewText(R.id.text_time2, df.print(stop.getArrivalTime()));
contentView.setViewVisibility(R.id.text_time2, View.VISIBLE);
contentView.setTextViewText(R.id.text_delay2, String.valueOf(stop.getArrivalDelay().getStandardMinutes()));
contentView.setViewVisibility(R.id.text_delay2, View.VISIBLE);
contentView.setTextViewText(R.id.text_station, stop.getStation().getLocalizedName());
contentView.setViewVisibility(R.id.text_station, View.VISIBLE);
contentView.setTextViewText(R.id.text_platform, stop.getPlatform());
contentView.setViewVisibility(R.id.layout_platform_container, View.VISIBLE);
return contentView;
}
示例7: setContent
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setContent(RemoteViews row, Note note) {
/* see also HeadsListViewAdapter.bindView */
OrgHead head = note.getHead();
row.setTextViewText(R.id.item_list_widget_title, titleGenerator.generateTitle(note, head));
/* Closed time. */
if (head.hasClosed() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_closed_text, userTimeFormatter.formatAll(head.getClosed()));
row.setViewVisibility(R.id.item_list_widget_closed, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_closed, View.GONE);
}
/* Deadline time. */
if (head.hasDeadline() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_deadline_text, userTimeFormatter.formatAll(head.getDeadline()));
row.setViewVisibility(R.id.item_list_widget_deadline, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_deadline, View.GONE);
}
/* Scheduled time. */
if (head.hasScheduled() && AppPreferences.displayPlanning(mContext)) {
row.setTextViewText(R.id.item_list_widget_scheduled_text, userTimeFormatter.formatAll(head.getScheduled()));
row.setViewVisibility(R.id.item_list_widget_scheduled, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_scheduled, View.GONE);
}
if (AppPreferences.todoKeywordsSet(mContext).contains(head.getState())) {
row.setViewVisibility(R.id.item_list_widget_done, View.VISIBLE);
} else {
row.setViewVisibility(R.id.item_list_widget_done, View.GONE);
}
}
示例8: defaultAppWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void defaultAppWidget(Context context, int[] appWidgetIds) {
final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.widget);
views.setTextViewText(R.id.title, "Hello");
views.setTextViewText(R.id.artist, "Adele");
controls(views, context);
pushUpdate(context, appWidgetIds, views);
}
示例9: getLoadingView
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getLoadingView() {
RemoteViews loadingView = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_loading);
loadingView.setTextViewText(R.id.loadingText, context.getString(R.string.mail_list_widget_loading));
loadingView.setViewVisibility(R.id.loadingText, View.VISIBLE);
return loadingView;
}
示例10: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteViews = new RemoteViews(
context.getPackageName(), R.layout.item_package_for_widget);
Realm rlm = Realm.getInstance(new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.name(DATABASE_NAME)
.build());
List<Package> results = rlm.copyFromRealm(rlm.where(Package.class)
.notEqualTo("state", String.valueOf(Package.STATUS_DELIVERED))
.findAllSorted("timestamp", Sort.DESCENDING));
Package p = results.get(position);
if (p.getData() != null && p.getData().size() > 0) {
int state = Integer.parseInt(p.getState());
remoteViews.setTextViewText(R.id.textViewStatus,
String.valueOf(packageStatus[state]) + " - " + p.getData().get(0).getContext());
remoteViews.setTextViewText(R.id.textViewTime, p.getData().get(0).getTime());
} else {
remoteViews.setTextViewText(R.id.textViewTime, "");
remoteViews.setTextViewText(R.id.textViewStatus, statusError);
}
remoteViews.setTextViewText(R.id.textViewPackageName, p.getName());
remoteViews.setTextViewText(R.id.textViewAvatar, p.getName().substring(0, 1));
remoteViews.setImageViewResource(R.id.imageViewAvatar, p.getColorAvatar());
Intent intent = new Intent();
intent.putExtra(PackageDetailsActivity.PACKAGE_ID, p.getNumber());
remoteViews.setOnClickFillInIntent(R.id.layoutPackageItemMain, intent);
return remoteViews;
}
示例11: 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;
}
示例12: defaultAppWidget
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* Initialize given widgets to default state, where we launch UltraSonic 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(), this.layoutId);
views.setTextViewText(R.id.artist, res.getText(R.string.widget_initial_text));
linkButtons(context, views, false);
pushUpdate(context, appWidgetIds, views);
}
示例13: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
if (position < mItems.size()) {
String category = mItems.get(position).getCategory();
if (category == null || category.equals("")) {
rv.setTextViewText(R.id.category, getString(R.string.edit_category_empty));
} else {
rv.setTextViewText(R.id.category, category);
}
String type = mItems.get(position).getType();
if (type == null || type.equals("")) {
rv.setTextViewText(R.id.type, getString(R.string.edit_type_empty));
} else {
rv.setTextViewText(R.id.type, type);
}
String colour = mItems.get(position).getMainColour();
if (colour == null || colour.equals("")) {
rv.setTextViewText(R.id.colour, getString(R.string.edit_main_colour_empty));
} else {
rv.setTextViewText(R.id.colour, colour);
}
long expiry = mItems.get(position).getExpiry();
if (expiry == -1) {
setTextColourPrimary(rv);
rv.setTextViewText(R.id.expiry, getString(R.string.edit_expiry_date_empty));
} else {
Calendar expiryDate = Calendar.getInstance();
expiryDate.setTimeInMillis(expiry);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(getString(
R.string.edit_date_format),
Locale.ENGLISH);
String expiryString = simpleDateFormat.format(expiryDate.getTime());
rv.setTextViewText(R.id.expiry, expiryString);
Calendar almostExpiredDate = Calendar.getInstance();
almostExpiredDate.add(Calendar.MONTH, 1);
if (expiryDate.compareTo(Calendar.getInstance()) < 1) {
rv.setInt(R.id.expiry, "setTextColor", ContextCompat.getColor(mContext,
R.color.red));
} else if (expiryDate.compareTo(almostExpiredDate) < 1) {
rv.setInt(R.id.expiry, "setTextColor", ContextCompat.getColor(mContext,
R.color.orange));
} else {
setTextColourPrimary(rv);
}
}
int price = mItems.get(position).getPricePaid();
String priceString;
if (price == -1) {
priceString = getString(R.string.edit_price_paid_empty);
} else {
priceString = getString(R.string.edit_price_paid_prefix)
+ getPriceFromTotalCents(price);
}
rv.setTextViewText(R.id.paid, priceString);
Intent fillInIntent = new Intent();
fillInIntent.putExtra(EXTRA_ITEM_ID, mItems.get(position).getId());
rv.setOnClickFillInIntent(R.id.widget_item, fillInIntent);
}
return rv;
}
示例14: setNextScheduledAlarm
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setNextScheduledAlarm(Context context, RemoteViews widget) {
String nextAlarm = getNextAlarm(context);
if (TextUtils.isEmpty(nextAlarm)) {
widget.setViewVisibility(R.id.alarm_text, View.INVISIBLE);
} else {
widget.setTextViewText(R.id.alarm_text, nextAlarm);
widget.setViewVisibility(R.id.alarm_text, View.VISIBLE);
}
}
示例15: performUpdate
import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
* Update all active widget instances by pushing changes
*/
public void performUpdate(final MusicService service, final int[] appWidgetIds) {
final RemoteViews appWidgetView = new RemoteViews(service.getPackageName(), R.layout.app_widget_small);
final boolean isPlaying = service.isPlaying();
final Song song = service.getCurrentSong();
// Set the titles and artwork
if (TextUtils.isEmpty(song.title) && TextUtils.isEmpty(song.artistName)) {
appWidgetView.setViewVisibility(R.id.media_titles, View.INVISIBLE);
} else {
if (TextUtils.isEmpty(song.title) || TextUtils.isEmpty(song.artistName)) {
appWidgetView.setTextViewText(R.id.text_separator, "");
} else {
appWidgetView.setTextViewText(R.id.text_separator, "•");
}
appWidgetView.setViewVisibility(R.id.media_titles, View.VISIBLE);
appWidgetView.setTextViewText(R.id.title, song.title);
appWidgetView.setTextViewText(R.id.text, song.artistName);
}
// Set correct drawable for pause state
int playPauseRes = isPlaying ? R.drawable.ic_pause_white_24dp : R.drawable.ic_play_arrow_white_24dp;
appWidgetView.setImageViewBitmap(R.id.button_toggle_play_pause, createBitmap(Util.getTintedVectorDrawable(service, playPauseRes, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));
// Set prev/next button drawables
appWidgetView.setImageViewBitmap(R.id.button_next, createBitmap(Util.getTintedVectorDrawable(service, R.drawable.ic_skip_next_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));
appWidgetView.setImageViewBitmap(R.id.button_prev, createBitmap(Util.getTintedVectorDrawable(service, R.drawable.ic_skip_previous_white_24dp, MaterialValueHelper.getSecondaryTextColor(service, false)), 1f));
// Link actions buttons to intents
linkButtons(service, appWidgetView);
// Load the album cover async and push the update on completion
final Context appContext = service.getApplicationContext();
final int widgetImageSize = service.getResources().getDimensionPixelSize(R.dimen.app_widget_small_image_size);
service.runOnUiThread(new Runnable() {
@Override
public void run() {
if (target != null) {
Glide.clear(target);
}
target = SongGlideRequest.Builder.from(Glide.with(appContext), song)
.checkIgnoreMediaStore(appContext)
.asBitmap().build()
.into(new SimpleTarget<Bitmap>(widgetImageSize, widgetImageSize) {
@Override
public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
update(resource);
}
@Override
public void onLoadFailed(Exception e, Drawable errorDrawable) {
super.onLoadFailed(e, errorDrawable);
update(null);
}
private void update(@Nullable Bitmap bitmap) {
appWidgetView.setViewVisibility(R.id.image, View.VISIBLE);
if (bitmap == null) {
appWidgetView.setImageViewResource(R.id.image, R.drawable.default_album_art);
} else {
appWidgetView.setImageViewBitmap(R.id.image, bitmap);
}
pushUpdate(appContext, appWidgetIds, appWidgetView);
}
});
}
});
}