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


Java RemoteViews.setTextViewText方法代碼示例

本文整理匯總了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);
}
 
開發者ID:UTN-FRBA-Mobile,項目名稱:Clases-2017c1,代碼行數:18,代碼來源:HiAppWidget.java

示例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;
}
 
開發者ID:anthorlop,項目名稱:AJCPlayer,代碼行數:22,代碼來源:VideoPlayerActivity.java

示例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;

}
 
開發者ID:benniaobuguai,項目名稱:android-project-gallery,代碼行數:60,代碼來源:DownloadService.java

示例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;
}
 
開發者ID:anthorlop,項目名稱:AJCPlayer,代碼行數:27,代碼來源:SecondAudioActivity.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_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);
}
 
開發者ID:89luca89,項目名稱:ThunderMusic,代碼行數:20,代碼來源:MediaAppWidgetProvider4x2_Light.java

示例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;
}
 
開發者ID:hyperrail,項目名稱:hyperrail-for-android,代碼行數:18,代碼來源:NotificationLayoutBuilder.java

示例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);
    }
}
 
開發者ID:orgzly,項目名稱:orgzly-android,代碼行數:36,代碼來源:ListWidgetViewsFactory.java

示例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);
}
 
開發者ID:RajneeshSingh007,項目名稱:MusicX-music-player,代碼行數:8,代碼來源:MusicxWidget4x2.java

示例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;
}
 
開發者ID:philipwhiuk,項目名稱:q-mail,代碼行數:8,代碼來源:MessageListRemoteViewFactory.java

示例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;
}
 
開發者ID:TonnyL,項目名稱:Espresso,代碼行數:36,代碼來源:WidgetListFactory.java

示例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;
}
 
開發者ID:reyanshmishra,項目名稱:Rey-MusicPlayer,代碼行數:38,代碼來源:QueueWidgetService.java

示例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);
}
 
開發者ID:ultrasonic,項目名稱:ultrasonic,代碼行數:15,代碼來源:UltraSonicAppWidgetProvider.java

示例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;
}
 
開發者ID:mvescovo,項目名稱:item-reaper,代碼行數:63,代碼來源:WidgetListService.java

示例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);
    }

}
 
開發者ID:WeAreFairphone,項目名稱:android_packages_apps_ClockWidget,代碼行數:12,代碼來源:ClockWidget.java

示例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);
                        }
                    });
        }
    });
}
 
開發者ID:aliumujib,項目名稱:Orin,代碼行數:73,代碼來源:AppWidgetSmall.java


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