当前位置: 首页>>代码示例>>Java>>正文


Java RemoteViews类代码示例

本文整理汇总了Java中android.widget.RemoteViews的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews类的具体用法?Java RemoteViews怎么用?Java RemoteViews使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RemoteViews类属于android.widget包,在下文中一共展示了RemoteViews类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateBigContentView

import android.widget.RemoteViews; //导入依赖的package包/类
private static <T extends Action> RemoteViews generateBigContentView(Context context, CharSequence contentTitle, CharSequence contentText, CharSequence contentInfo, int number, Bitmap largeIcon, CharSequence subText, boolean useChronometer, long when, List<T> actions, boolean showCancelButton, PendingIntent cancelButtonIntent) {
    int actionCount = Math.min(actions.size(), 5);
    RemoteViews big = applyStandardTemplate(context, contentTitle, contentText, contentInfo, number, largeIcon, subText, useChronometer, when, getBigLayoutResource(actionCount), false);
    big.removeAllViews(R.id.media_actions);
    if (actionCount > 0) {
        for (int i = 0; i < actionCount; i++) {
            big.addView(R.id.media_actions, generateMediaActionButton(context, (Action) actions.get(i)));
        }
    }
    if (showCancelButton) {
        big.setViewVisibility(R.id.cancel_action, 0);
        big.setInt(R.id.cancel_action, "setAlpha", context.getResources().getInteger(R.integer.cancel_button_image_alpha));
        big.setOnClickPendingIntent(R.id.cancel_action, cancelButtonIntent);
    } else {
        big.setViewVisibility(R.id.cancel_action, 8);
    }
    return big;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:NotificationCompatImplBase.java

示例2: updateAppWidget

import android.widget.RemoteViews; //导入依赖的package包/类
private void updateAppWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId) {
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_layout);

    views.setTextViewText(R.id.folder, context.getString(R.string.integrated_inbox_title));

    Intent intent = new Intent(context, MessageListWidgetService.class);
    intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
    intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
    views.setRemoteAdapter(R.id.listView, intent);

    PendingIntent viewAction = viewActionTemplatePendingIntent(context);
    views.setPendingIntentTemplate(R.id.listView, viewAction);

    PendingIntent composeAction = composeActionPendingIntent(context);
    views.setOnClickPendingIntent(R.id.new_message, composeAction);

    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:19,代码来源:MessageListWidgetProvider.java

示例3: 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

示例4: onUpdate

import android.widget.RemoteViews; //导入依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // update each of the widgets with the remote adapter
    for (int i = 0; i < appWidgetIds.length; ++i) {

        // Here we setup the intent which points to the StackViewService which will
        // provide the views for this collection.
        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        // When intents are compared, the extras are ignored, so we need to embed the extras
        // into the data so that the extras will not be ignored.
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        // The empty view is displayed when the collection has no items. It should be a sibling
        // of the collection view.
        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        // Here we setup the a pending intent template. Individuals items of a collection
        // cannot setup their own pending intents, instead, the collection as a whole can
        // setup a pending intent template, and the individual items can set a fillInIntent
        // to create unique before on an item to item basis.
        Intent toastIntent = new Intent(context, StackWidgetProvider.class);
        toastIntent.setAction(StackWidgetProvider.TOAST_ACTION);
        toastIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent toastPendingIntent = PendingIntent.getBroadcast(context, 0, toastIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, toastPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:sdrausty,项目名称:buildAPKsSamples,代码行数:36,代码来源:StackWidgetProvider.java

示例5: updateWidgets

import android.widget.RemoteViews; //导入依赖的package包/类
private static void updateWidgets(Context context, AppWidgetManager manager, int[] appWidgetIds, boolean nextAccount) {
    Log.d("FinancistoWidget", "updateWidgets " + Arrays.toString(appWidgetIds) + " -> " + nextAccount);
    for (int id : appWidgetIds) {
        AppWidgetProviderInfo appWidgetInfo = manager.getAppWidgetInfo(id);
        if (appWidgetInfo != null) {
            int layoutId = appWidgetInfo.initialLayout;
            if (MyPreferences.isWidgetEnabled(context)) {
                long accountId = loadAccountForWidget(context, id);
                Class providerClass = getProviderClass(appWidgetInfo);
                Log.d("FinancistoWidget", "using provider " + providerClass);
                RemoteViews remoteViews = nextAccount || accountId == -1
                        ? buildUpdateForNextAccount(context, id, layoutId, providerClass, accountId)
                        : buildUpdateForCurrentAccount(context, id, layoutId, providerClass, accountId);
                manager.updateAppWidget(id, remoteViews);
            } else {
                manager.updateAppWidget(id, noDataUpdate(context, layoutId));
            }
        }
    }
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:21,代码来源:AccountWidget.java

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

示例7: getViewAt

import android.widget.RemoteViews; //导入依赖的package包/类
@Override
    // 返回item对应的子View
    public RemoteViews getViewAt(int position) {
        Logger.INSTANCE.i(" --> getViewAt");
        if (mNotes.get(position) == null) {
            return null;
        }
        RemoteViews rv = new RemoteViews(context.getPackageName(),
                R.layout.app_widget_notes_item);
        Note note = mNotes.get(position);

        rv.setTextViewText(R.id.ic_notes_item_title_tv, note.getLabel());
        rv.setTextViewText(R.id.ic_notes_item_content_tv, note.getContent());
        rv.setTextViewText(R.id.ic_notes_item_data_tv, context.getString(R.string.note_log_text, context.getString(R.string.create),
                TimeUtils.getTime(note.getCreateTime())));
//        if (StringUtils.isEmpty(note.getImagePath()) || "[]".equals(note.getImagePath())) {
//            rv.setViewVisibility(R.id.ic_small_pic, Visibility);
//        } else {
//            rv.
//            holder.setVisible(R.id.small_pic, true);
//            ImageUtils.INSTANCE.showThumbnail(mContext, note.getImagePath(), (ImageView) holder.getView(R.id.small_pic));
//        }

        loadItemOnClickExtras(rv, position);
        return rv;
    }
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:27,代码来源:NotesRemoteViewsFactory.java

示例8: onUpdate

import android.widget.RemoteViews; //导入依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    for (int i = 0; i < appWidgetIds.length; ++i) {

        Intent intent = new Intent(context, StackWidgetService.class);
        intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        RemoteViews rv = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
        rv.setRemoteAdapter(appWidgetIds[i], R.id.stack_view, intent);

        rv.setEmptyView(R.id.stack_view, R.id.empty_view);

        Intent widgetIntent = new Intent(context, StackWidgetProvider.class);
        widgetIntent.setAction(StackWidgetProvider.WIDGET_ACTION);
        widgetIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);
        intent.setData(Uri.parse(intent.toUri(Intent.URI_INTENT_SCHEME)));
        PendingIntent widgetPendingIntent = PendingIntent.getBroadcast(context, 0, widgetIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);
        rv.setPendingIntentTemplate(R.id.stack_view, widgetPendingIntent);

        appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
    }
    super.onUpdate(context, appWidgetManager, appWidgetIds);
}
 
开发者ID:MuditSrivastava,项目名称:Canvas-Vision,代码行数:25,代码来源:StackWidgetProvider.java

示例9: addView

import android.widget.RemoteViews; //导入依赖的package包/类
private void addView()
{
	NavBarEntry entry = navBarEntryFromView();
	if (entry == null) return;

	RemoteViews remoteViews = createRemoteViewsId(entry);
	if (remoteViews == null) return;

	NavBarExServiceMgr navBarExServiceMgr = (NavBarExServiceMgr) getSystemService(Context.NAVBAREX_SERVICE);

	String id = navBarExServiceMgr.addView(entry.priority, remoteViews);
	if (TextUtils.isEmpty(id))
	{
		Toast.makeText(this, "Failed to add remote views. Returned null.", Toast.LENGTH_SHORT).show();
		return;
	}
	settings.getIdsMap().put(id, entry);
	settings.saveDeferred();

	fillListView();
	fillViews();
}
 
开发者ID:ryanchyshyn,项目名称:aosp_nav_bar_ex,代码行数:23,代码来源:MainActivity.java

示例10: buildUpdate

import android.widget.RemoteViews; //导入依赖的package包/类
private RemoteViews buildUpdate(Context context) {
	RemoteViews updateViews = new RemoteViews(context.getPackageName(), R.layout.widget);

	AudioManager audioManager = (AudioManager) context.getSystemService(Activity.AUDIO_SERVICE);
	if (audioManager.getRingerMode() == AudioManager.RINGER_MODE_SILENT) {
		updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_normal);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
	} else {
		updateViews.setImageViewResource(R.id.phoneState, R.drawable.phone_state_silent);
		audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
	}

	Intent i = new Intent(this, AppWidget.class);
	PendingIntent pi = PendingIntent.getBroadcast(context, 0, i, 0);
	updateViews.setOnClickPendingIntent(R.id.phoneState, pi);

	return updateViews;

}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:20,代码来源:AppWidget.java

示例11: 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

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

}
 
开发者ID:WeAreFairphone,项目名称:android_packages_apps_ClockWidget,代码行数:23,代码来源:ClockWidget.java

示例13: onUpdate

import android.widget.RemoteViews; //导入依赖的package包/类
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
    // Perform this loop procedure for each App Widget that belongs to this provider
    for (int i = 0; i < appWidgetIds.length; i++) {
        int appWidgetId = appWidgetIds[i];

        // Get the layout for the App Widget and attach an on-click listener
        // to the button
        RemoteViews views = new RemoteViews(context.getPackageName(),
                R.layout.garage_door_widget);

        Intent intent = new Intent(context, GarageDoorIntentService.class);
        PendingIntent pendingIntent = PendingIntent.getService(
                context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
        views.setOnClickPendingIntent(R.id.widget_layout, pendingIntent);

        // Tell the AppWidgetManager to perform an update on the current app widget
        appWidgetManager.updateAppWidget(appWidgetId, views);
    }
}
 
开发者ID:jpuderer,项目名称:GarageDoor,代码行数:21,代码来源:GarageDoorWidgetProvider.java

示例14: updateAppWidget

import android.widget.RemoteViews; //导入依赖的package包/类
static void updateAppWidget(Context context, AppWidgetManager appWidgetManager,
                            int appWidgetId) {

    setCountersDK(context);
    setCountersIO(context);
    setCountersFromPreferences(context);

    // Construct the RemoteViews object
    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.kaem_widget);
    views.setTextViewText(R.id.dk_kaem_users, dkUsersCount);
    views.setTextViewText(R.id.dk_kaem_projects, dkProjectsCount);
    views.setTextViewText(R.id.dk_kaem_teams, dkTeamsCount);
    views.setTextViewText(R.id.dk_kaem_lookups, dkLookupsCount);

    views.setTextViewText(R.id.io_kaem_users, ioUsersCount);
    views.setTextViewText(R.id.io_kaem_projects, ioProjectsCount);
    views.setTextViewText(R.id.io_kaem_teams, ioTeamsCount);
    views.setTextViewText(R.id.io_kaem_lookups, ioLookupsCount);

    // Pending intent for refresh button
    Intent intent = new Intent(REFRESH_BUTTON);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
    views.setOnClickPendingIntent(R.id.REFRESH_BUTTON, pendingIntent);

    // Instruct the widget manager to update the widget
    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:KAEM,项目名称:android-widget,代码行数:28,代码来源:KaemWidget.java

示例15: getViewAt

import android.widget.RemoteViews; //导入依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
    RemoteViews rowView = new RemoteViews(_context.getPackageName(), R.layout.widget_file_item);
    rowView.setTextViewText(R.id.widget_note_title, "???");
    if (position < _widgetFilesList.length) {
        File file = _widgetFilesList[position];
        Intent fillInIntent = new Intent().putExtra(DocumentIO.EXTRA_PATH, file);
        rowView.setTextViewText(R.id.widget_note_title, MarkdownTextConverter.MD_EXTENSION_PATTERN.matcher(file.getName()).replaceAll(""));
        rowView.setOnClickFillInIntent(R.id.widget_note_title, fillInIntent);
    }
    return rowView;
}
 
开发者ID:gsantner,项目名称:markor,代码行数:13,代码来源:FilesWidgetFactory.java


注:本文中的android.widget.RemoteViews类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。