本文整理汇总了Java中android.widget.RemoteViews.setInt方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setInt方法的具体用法?Java RemoteViews.setInt怎么用?Java RemoteViews.setInt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setInt方法的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;
}
示例2: 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());
}
}
示例3: fixIconImage
import android.widget.RemoteViews; //导入方法依赖的package包/类
void fixIconImage(Resources resources, RemoteViews remoteViews, boolean hasIconBitmap, Notification notification) {
if (remoteViews == null) return;
if (!mNotificationCompat.isSystemLayout(remoteViews)) {
return;
}
try {
//noinspection deprecation
int id = R_Hide.id.icon.get();
//only fake small icon
if (!hasIconBitmap && notification.largeIcon == null) {
Drawable drawable = resources.getDrawable(notification.icon);
drawable.setLevel(notification.iconLevel);
Bitmap bitmap = drawableToBitMap(drawable);
remoteViews.setImageViewBitmap(id, bitmap);
}
if (Build.VERSION.SDK_INT >= 21) {
remoteViews.setInt(id, "setBackgroundColor", Color.TRANSPARENT);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
remoteViews.setViewPadding(id, 0, 0, 0, 0);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews remoteView = new RemoteViews(context.getPackageName(), R.layout.message_list_widget_list_item);
MailItem item = mailItems.get(position);
CharSequence sender = item.unread ? bold(item.sender) : item.sender;
CharSequence subject = item.unread ? bold(item.subject) : item.subject;
if (senderAboveSubject) {
remoteView.setTextViewText(R.id.sender, sender);
remoteView.setTextViewText(R.id.mail_subject, subject);
} else {
remoteView.setTextViewText(R.id.sender, subject);
remoteView.setTextViewText(R.id.mail_subject, sender);
}
remoteView.setTextViewText(R.id.mail_date, item.getDateFormatted("%d %s"));
remoteView.setTextViewText(R.id.mail_preview, item.preview);
int textColor = item.getTextColor();
remoteView.setTextColor(R.id.sender, textColor);
remoteView.setTextColor(R.id.mail_subject, textColor);
remoteView.setTextColor(R.id.mail_date, textColor);
remoteView.setTextColor(R.id.mail_preview, textColor);
if (item.hasAttachment) {
remoteView.setInt(R.id.attachment, "setVisibility", View.VISIBLE);
} else {
remoteView.setInt(R.id.attachment, "setVisibility", View.GONE);
}
Intent intent = new Intent();
intent.setData(item.uri);
remoteView.setOnClickFillInIntent(R.id.mail_list_item, intent);
return remoteView;
}
示例5: settingUpViews
import android.widget.RemoteViews; //导入方法依赖的package包/类
private static void settingUpViews(Context context, int appWidgetId) {
CharSequence widgetText = context.getString(R.string.appwidget_text_loading);
int backgroundColor = AppWidgetConfigureActivity.loadBackgroundColorPref(context, appWidgetId);
int buttonColor = AppWidgetConfigureActivity.loadButtonColorPref(context, appWidgetId);
int textColor = AppWidgetConfigureActivity.loadTextColorPref(context, appWidgetId);
// Construct the RemoteViews object
views = new RemoteViews(context.getPackageName(), R.layout.app_widget);
views.setTextViewText(R.id.appwidgetText, widgetText);
views.setTextViewTextSize(R.id.appwidgetText, TypedValue.COMPLEX_UNIT_SP, AppSettings.textSizeWidget(context));
views.setInt(R.id.relativeLayout, "setBackgroundColor", backgroundColor);
views.setTextColor(R.id.updateButton, buttonColor);
views.setTextColor(R.id.appwidgetText, textColor);
}
示例6: setTableCell
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setTableCell(Context context, RemoteViews views, int row,
int col, int color, CourseInfo course) {
int table_cell_id = context.getResources().getIdentifier(
"course_widget_cell_" + row + "_" + col, "id",
context.getPackageName());
views.setInt(table_cell_id, "setBackgroundColor", color);
views.setTextViewText(table_cell_id, course.getCourseName());
}
示例7: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
public RemoteViews getViewAt(int position) {
RemoteViews rv = new RemoteViews(mContext.getPackageName(), R.layout.widget_item);
if (!mCursor.moveToPosition(position)) {
return null;
}
int idIndex = mCursor.getColumnIndex(TaskItemsContract.TaskItemsColumns._ID);
int itemDescriptionIndex = mCursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_DESCRIPTION);
int backColor = mCursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_COLOR);
int isFinishedIndex = mCursor.getColumnIndex(TaskItemsContract.TaskItemsColumns.COLUMN_NAME_IS_FINISHED);
int id = mCursor.getInt(idIndex);
String description = mCursor.getString(itemDescriptionIndex);
int color = mCursor.getInt(backColor);
int isFinished = mCursor.getInt(isFinishedIndex);
rv.setTextColor(R.id.item, color);
if (isFinished == 1) {
rv.setInt(R.id.item, "setPaintFlags", Paint.STRIKE_THRU_TEXT_FLAG | Paint.ANTI_ALIAS_FLAG);
rv.setTextViewText(R.id.item, description);
} else {
rv.setInt(R.id.item, "setPaintFlags", Paint.ANTI_ALIAS_FLAG);
rv.setTextViewText(R.id.item, description);
}
Bundle extras = new Bundle();
extras.putInt(TodayWidgetProvider.EXTRA_ITEM, position);
Intent fillInIntent = new Intent();
fillInIntent.putExtras(extras);
rv.setOnClickFillInIntent(R.id.item, fillInIntent);
return rv;
}
示例8: 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 appWidgetId : appWidgetIds) {
// Get the layout for the App Widget and attach an on-click listener
// to the button
RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.service_toggle_widget);
if (NLService.isEnabled()) {
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));
} else {
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));
}
views.setOnClickPendingIntent(
R.id.widgetToggleButton,
getPendingSelfIntent(context, appWidgetId, TOGGLE_CLICKED));
// Tell the AppWidgetManager to perform an update on the current app widget
appWidgetManager.updateAppWidget(appWidgetId, views);
}
}
示例9: 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);
}
}
示例10: configureSettingsButton
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void configureSettingsButton(RemoteViews bigView) {
if (mSettingsAction == null) {
return;
}
bigView.setOnClickPendingIntent(R.id.origin, mSettingsAction.intent);
if (useMaterial()) {
bigView.setInt(R.id.origin_settings_icon, "setColorFilter", BUTTON_ICON_COLOR_MATERIAL);
}
}
示例11: 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;
}
示例12: setTextColourPrimary
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void setTextColourPrimary(RemoteViews rv) {
TypedValue typedValue = new TypedValue();
TypedArray typedArray = mContext.obtainStyledAttributes(
typedValue.data, new int[]{android.R.attr.textColorPrimary}
);
int textColourPrimary = typedArray.getColor(0, 0);
typedArray.recycle();
rv.setInt(R.id.expiry, "setTextColor", textColourPrimary);
}
示例13: 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;
}
示例14: cleanTable
import android.widget.RemoteViews; //导入方法依赖的package包/类
private void cleanTable(Context context, RemoteViews views) {
for (int row = 1; row < TABLE_ROW; row++) {
for (int col = 1; col < TABLE_COL; col++) {
int table_cell_id = context.getResources().getIdentifier(
"course_widget_cell_" + row + "_" + col, "id",
context.getPackageName());
views.setInt(table_cell_id, "setBackgroundColor",
Color.TRANSPARENT);
views.setTextViewText(table_cell_id, null);
}
}
}
示例15: getViewAt
import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
RemoteViews row = new RemoteViews(context.getPackageName(),
R.layout.calender_cell);
CalendarCell cell = daysList.get(position);
Intent islamicIntent = new Intent();
Bundle islamicIntentExtras = new Bundle();
islamicIntentExtras.putString("islamic_day",
NumbersLocal.convertNumberType(context, cell.day + ""));
islamicIntent.putExtras(islamicIntentExtras);
Intent gregorianIntent = new Intent();
Bundle gregorianIntentExtras = new Bundle();
gregorianIntentExtras.putString("gregorian_day",
NumbersLocal.convertNumberType(context, cell.dayOther + ""));
gregorianIntent.putExtras(gregorianIntentExtras);
//not empty date
if (cell.day != -1) {
//set dates in calender
row.setViewVisibility(R.id.textView31, View.VISIBLE);
row.setViewVisibility(R.id.textView30, View.VISIBLE);
row.setTextViewText(R.id.textView31, NumbersLocal.convertToNumberTypeSystem(context, cell.dayOther + ""));
row.setTextViewText(R.id.textView30, NumbersLocal.convertToNumberTypeSystem(context, cell.day + ""));
//get current day
HGDate hgDate = new HGDate();
hgDate.toHigri();
//check if that is the current day or not
if (cell.day == hgDate.getDay()) {
row.setTextColor(R.id.textView31, Color.WHITE);
row.setTextColor(R.id.textView30, Color.WHITE);
row.setInt(R.id.textView31, "setBackgroundColor", Color.argb(255, 73, 138, 127));
row.setInt(R.id.textView30, "setBackgroundColor", Color.argb(255, 73, 138, 127));
} else {
row.setTextColor(R.id.textView31, Color.GRAY);
row.setTextColor(R.id.textView30, Color.BLACK);
row.setInt(R.id.textView31, "setBackgroundColor", Color.WHITE);
row.setInt(R.id.textView30, "setBackgroundColor", Color.WHITE);
}
//check if the day one of the islamic events
for (Event event : eventList) {
String[] date = event.hejriDate.split("-");
if (cell.day == Integer.parseInt(date[0]) && cell.hijriMonth == Integer.parseInt(date[1])) {
row.setInt(R.id.textView31, "setBackgroundColor", Color.YELLOW);
row.setInt(R.id.textView30, "setBackgroundColor", Color.YELLOW);
}
}
} else {
//hide empty cellls
row.setViewVisibility(R.id.textView31, View.GONE);
row.setViewVisibility(R.id.textView30, View.GONE);
}
row.setOnClickFillInIntent(R.id.textView31, gregorianIntent);
row.setOnClickFillInIntent(R.id.textView30, islamicIntent);
return (row);
}