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


Java RemoteViews.setTextColor方法代码示例

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


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

示例1: 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());
    }
}
 
开发者ID:abicelis,项目名称:PingWidget,代码行数:25,代码来源:RemoteViewsUtil.java

示例2: testNotificationAdapter

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Test
public void testNotificationAdapter() {
    final String NOTIFICATION_TEXT = "adapter-text";
    final String NOTIFICATION_TITLE = "adapter-title";
    final long TIMEOUT = 5000;

    Context appContext = InstrumentationRegistry.getTargetContext();

    RemoteViews contentView = new RemoteViews("cn.dreamtobe.toolset.test", R.layout.custom_layout);
    contentView.setTextViewText(R.id.title, NOTIFICATION_TITLE);
    contentView.setTextViewText(R.id.text, NOTIFICATION_TEXT);

    // Fix the Notification-Style problem ---------------
    // Set the default title style color to title view.
    contentView.setTextColor(R.id.title, NotificationAdapter.getTitleColor(appContext));
    // Set the default title style size to title view
    contentView.setTextViewTextSize(R.id.title, COMPLEX_UNIT_PX, NotificationAdapter.getTitleSize(appContext));
    // Set the default text style color to text view
    contentView.setTextColor(R.id.text, NotificationAdapter.getTextColor(appContext));
    // Set the default text style size to text view
    contentView.setTextViewTextSize(R.id.text, COMPLEX_UNIT_PX, NotificationAdapter.getTextSize(appContext));
    // End fix the Notification-Style problem ---------------

    Notification notification = new Notification();
    notification.icon = R.drawable.ic_launcher;
    notification.contentView = contentView;

    notification.flags |= Notification.FLAG_AUTO_CANCEL;
    notification.defaults |= Notification.DEFAULT_SOUND;
    notification.defaults |= Notification.DEFAULT_VIBRATE;

    NotificationManager notifyMgr =
            (NotificationManager) appContext.getSystemService(NOTIFICATION_SERVICE);
    notifyMgr.notify(1, notification);

    UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
    device.openNotification();
    device.wait(Until.hasObject(By.text(NOTIFICATION_TITLE)), TIMEOUT);
}
 
开发者ID:Jacksgong,项目名称:notification-adapter,代码行数:40,代码来源:NotificationAdapterTest.java

示例3: 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;
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:36,代码来源:MessageListRemoteViewFactory.java

示例4: 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);
}
 
开发者ID:personaljesusua,项目名称:DepressingThoughts,代码行数:15,代码来源:AppWidget.java

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

        }
 
开发者ID:vixir,项目名称:Perfect-Day,代码行数:31,代码来源:TodayWidgetService.java

示例6: 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);
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:29,代码来源:ServiceToggle.java

示例7: 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);
    }
}
 
开发者ID:abhijitvalluri,项目名称:fitnotifications,代码行数:33,代码来源:ServiceToggle.java

示例8: getViewAt

import android.widget.RemoteViews; //导入方法依赖的package包/类
@Override
public RemoteViews getViewAt(int position) {
    if (position == MAX_WIDGET_ROWS_LIMIT) {
        return showWidgetItemViewAll();
    }

    RemoteViews remoteViews = new RemoteViews(context.getPackageName(), R.layout.widget_item_coupon);
    remoteViews.setTextViewText(R.id.text_view_merchant, coupons.get(position).merchant);
    remoteViews.setTextViewText(R.id.text_view_category, coupons.get(position).category);
    remoteViews.setTextViewText(R.id.text_view_valid_until, Utilities.getStringDate(coupons.get(position).validUntil));
    remoteViews.setTextViewText(R.id.text_view_coupon_code, coupons.get(position).couponCode);

    int colorId = R.color.material_orange_900;
    String couponStateText = context.getString(R.string.coupon_state_available);
    if (coupons.get(position).state == 1) {
        colorId = R.color.material_green_700;
        couponStateText = context.getString(R.string.coupon_state_used);
    }
    remoteViews.setTextColor(R.id.text_view_coupon_state, ContextCompat.getColor(context.getApplicationContext(), colorId));
    remoteViews.setTextViewText(R.id.text_view_coupon_state, couponStateText);

    Bundle extras = new Bundle();
    extras.putInt(Constants.COUPON_FRAGMENT_MODE, CouponFragment.Mode.VIEW);
    extras.putParcelable(Constants.COUPON_PARCELABLE, coupons.get(position));
    if (!isTablet) {
        extras.putStringArrayList(Constants.BUNDLE_EXTRA_MERCHANT_SUGGESTIONS, new ArrayList<String>());
        extras.putStringArrayList(Constants.BUNDLE_EXTRA_CATEGORY_SUGGESTIONS, new ArrayList<String>());
    } else {
        extras.putBoolean(Constants.BUNDLE_EXTRA_LOAD_COUPON_FRAGMENT, true);
    }

    Intent fillInIntent = new Intent();
    fillInIntent.putExtras(extras);
    remoteViews.setOnClickFillInIntent(R.id.widget_row, fillInIntent);

    return remoteViews;
}
 
开发者ID:darsh2,项目名称:CouponsTracker,代码行数:38,代码来源:CouponRemoteViewsFactory.java

示例9: applyDefaultViewOn

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void applyDefaultViewOn(RemoteViews remoteViews) {
    remoteViews.setTextColor(R.id.widget_todo_list_item_title, context.getResources().getColor(R.color.dark_gray));
    remoteViews.setImageViewResource(R.id.widget_todo_list_item_details, R.drawable.ic_lightbulb_outline_gray_24dp);
    remoteViews.setViewVisibility(R.id.widget_todo_list_item_details, GONE);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:6,代码来源:WidgetListFactory.java

示例10: applyImportanceViewOn

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void applyImportanceViewOn(RemoteViews remoteViews, SpannableString title) {
    title.setSpan(new StyleSpan(Typeface.BOLD), 0, title.length(), 0);
    remoteViews.setTextColor(R.id.widget_todo_list_item_title, context.getResources().getColor(R.color.colorPrimary));
    remoteViews.setImageViewResource(R.id.widget_todo_list_item_details, R.drawable.ic_lightbulb_outline_primary_24dp);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:6,代码来源:WidgetListFactory.java

示例11: applyDoneViewOn

import android.widget.RemoteViews; //导入方法依赖的package包/类
private void applyDoneViewOn(RemoteViews remoteViews, SpannableString title) {
    StrikethroughSpan strikethroughSpan = new StrikethroughSpan();
    title.setSpan(strikethroughSpan, 0, title.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    remoteViews.setTextColor(R.id.widget_todo_list_item_title, context.getResources().getColor(R.color.light_gray));
    remoteViews.setImageViewResource(R.id.widget_todo_list_item_details, R.drawable.ic_lightbulb_outline_light_gray_24dp);
}
 
开发者ID:djuelg,项目名称:Neuronizer,代码行数:7,代码来源:WidgetListFactory.java

示例12: updateTime

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

    Log.d("AlarmMgrTime", Calendar.getInstance().getTime().toString());

    RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.clock_widget);
    Calendar now = Calendar.getInstance();

    // time
    views.setTextViewText(R.id.time, df_hm.format(now.getTime()));

    List<String> calendarList = LunarCalendar.getLunarCalendarStr(new Date());
    views.setTextViewText(R.id.solar_date, String.format(
            context.getString(R.string.solar_date_widget),
            calendarList.get(7),
            calendarList.get(9),
            calendarList.get(4)
    ));
    views.setTextViewText(R.id.lunar_date, String.format(
            context.getString(R.string.lunar_date),
            calendarList.get(1),
            calendarList.get(2)
    ));

    views.setTextViewText(R.id.week_day, weeks[now.get(Calendar.DAY_OF_WEEK) - 1]);

    String today = now.get(Calendar.DAY_OF_MONTH) + "";

    // tomorrow
    now.add(Calendar.DAY_OF_MONTH, 1);
    String tomorrow = now.get(Calendar.DAY_OF_MONTH) + "";

    // day after tomorrow
    now.add(Calendar.DAY_OF_MONTH, 1);
    String day_after_tomorrow = now.get(Calendar.DAY_OF_MONTH) + "";

    String[] dateStr = {today, tomorrow, day_after_tomorrow};

    // active day
    for (int i = 0; i < 3; i++) {
        if (i == activePos) {
            views.setTextColor(dateIds[i],
                    ContextCompat.getColor(context, R.color.textOrIcons));
            views.setInt(dateIds[i], "setBackgroundResource", R.drawable.circle_bg);
        } else {
            views.setTextColor(dateIds[i],
                    ContextCompat.getColor(context, R.color.secondaryText));
            views.setInt(dateIds[i], "setBackgroundResource", R.color.textOrIcons);
        }

        views.setTextViewText(dateIds[i], dateStr[i]);
    }

    views.setOnClickPendingIntent(R.id.today,
            switchDateIntent(context, SWITCH_TODAY_ACTION));
    views.setOnClickPendingIntent(R.id.tomorrow,
            switchDateIntent(context, SWITCH_TOMORROW_ACTION));
    views.setOnClickPendingIntent(R.id.day_after_tomorrow,
            switchDateIntent(context, SWITCH_DAY_AFTER_TOMORROW_ACTION));

    appWidgetManager.updateAppWidget(appWidgetId, views);
}
 
开发者ID:SEALiu,项目名称:Calendouer,代码行数:63,代码来源:ClockWidgetProvider.java

示例13: setContetView

import android.widget.RemoteViews; //导入方法依赖的package包/类
/**
   * 设置contentView
   * 
   */
  public void setContetView()
  {
// 在2.3到5.1以前, 通知栏的背景是黑色的, 所以RemoteView的背景色可以设置为透明
contentView = new RemoteViews(mContext.getPackageName(),R.layout.notification_trans);

boolean isRun= SPHelper.getBoolean(ConstantUtil.TOTAL_SWITCH,true);

boolean clipborad= SPHelper.getBoolean(ConstantUtil.MONITOR_CLIP_BOARD,true);
boolean click = SPHelper.getBoolean(ConstantUtil.MONITOR_CLICK,true);


String totalSwitch=!isRun?mContext.getString(R.string.notify_total_switch_off):mContext.getString(R.string.notify_total_switch_on);
String monitorClick=!click?mContext.getString(R.string.notify_monitor_click_off):mContext.getString(R.string.notify_monitor_click_on);
String monitorClipboard=!clipborad?mContext.getString(R.string.notify_monitor_clipboard_off):mContext.getString(R.string.notify_monitor_clipboard_on);

int totalSwitccRes=!isRun?R.drawable.notify_off:R.drawable.notify_on;
int monitorClickRes=!click?R.drawable.notify_click_off:R.drawable.notify_click_on;
int monitorClipboardRes=!clipborad?R.drawable.notify_clipboare_off:R.drawable.notify_clipboard_on;


int totalSwitccColor=!isRun?R.color.text_color_notify:R.color.colorPrimary;
int monitorClickColor=!click?R.color.text_color_notify:R.color.colorPrimary;
int monitorClipboardColor=!clipborad?R.color.text_color_notify:R.color.colorPrimary;


      //SettingActivity的跳转, 在SDK 3.0 (11)之上
      try {
	contentView.setViewVisibility(R.id.total_switch, View.VISIBLE);
	contentView.setOnClickPendingIntent(R.id.total_switch, createPendingIntent(mContext.getPackageName(),123456 ,ConstantUtil.TOTAL_SWITCH_BROADCAST));
	contentView.setTextViewText(R.id.total_switch, totalSwitch);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		contentView.setTextViewCompoundDrawables(R.id.total_switch,0,totalSwitccRes,0,0);
	}
	contentView.setTextColor(R.id.total_switch,mContext.getResources().getColor(totalSwitccColor));

	contentView.setViewVisibility(R.id.monitor_click, View.VISIBLE);
	contentView.setOnClickPendingIntent(R.id.monitor_click, createPendingIntent(mContext.getPackageName(), 123457 ,ConstantUtil.MONITOR_CLICK_BROADCAST));
	contentView.setTextViewText(R.id.monitor_click,monitorClick);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		contentView.setTextViewCompoundDrawables(R.id.monitor_click,0,monitorClickRes,0,0);
	}
	contentView.setTextColor(R.id.monitor_click,mContext.getResources().getColor(monitorClickColor));

	contentView.setViewVisibility(R.id.monitor_clipboard, View.VISIBLE);
	contentView.setOnClickPendingIntent(R.id.monitor_clipboard, createPendingIntent(mContext.getPackageName(), 123458 ,ConstantUtil.MONITOR_CLIPBOARD_BROADCAST));
	contentView.setTextViewText(R.id.monitor_clipboard,monitorClipboard);
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		contentView.setTextViewCompoundDrawables(R.id.monitor_clipboard,0,monitorClipboardRes,0,0);
	}
	contentView.setTextColor(R.id.monitor_clipboard,mContext.getResources().getColor(monitorClipboardColor));

	contentView.setViewVisibility(R.id.universal_copy, View.VISIBLE);
	contentView.setOnClickPendingIntent(R.id.universal_copy, createPendingIntent(mContext,  SplashActivity.class,ConstantUtil.NOTIFY_UNIVERSAL_COPY_BROADCAST));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		contentView.setTextViewCompoundDrawables(R.id.universal_copy,0,R.drawable.notify_copy,0,0);
	}

	contentView.setViewVisibility(R.id.screen_cap, View.VISIBLE);
	contentView.setOnClickPendingIntent(R.id.screen_cap, createPendingIntent(mContext,  ScreenCaptureActivity.class ,ConstantUtil.NOTIFY_SCREEN_CAPTURE_OVER_BROADCAST));
	if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
		contentView.setTextViewCompoundDrawables(R.id.screen_cap,0,R.drawable.notify_screen,0,0);
	}

} catch (Exception ignored) {
      } catch (Error error) {}
      contentView.setOnClickPendingIntent(R.id.Layout_notify_msearch, createPendingIntent(mContext,
		SettingActivity.class));
      notification.contentView = contentView;
  }
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:74,代码来源:BigbangNotification.java

示例14: 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);
}
 
开发者ID:fekracomputers,项目名称:MuslimMateAndroid,代码行数:68,代码来源:CalenderWidgetAdapter.java

示例15: onUpdate

import android.widget.RemoteViews; //导入方法依赖的package包/类
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
	final int N = appWidgetIds.length;

	Log.i("ExampleWidget",	"Updating widgets " + Arrays.asList(appWidgetIds));

	// Perform this loop procedure for each App Widget that belongs to this
	// provider
	for (int i = 0; i < N; i++) {
		int appWidgetId = appWidgetIds[i];

		// Create an Intent to launch MainActivity
		Intent intent = new Intent(context, MainActivity.class);
		PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,	intent, 0);

		// Get the layout for the App Widget and attach an on-click listener
		// to the button
		RemoteViews views = new RemoteViews(context.getPackageName(),
				R.layout.widgetlayout);
		
		views.setOnClickPendingIntent(R.id.ivCal, pendingIntent);
		views.setOnClickPendingIntent(R.id.tvParkStatus, pendingIntent);
		views.setOnClickPendingIntent(R.id.tvToday, pendingIntent);

		// To update a label
		views.setTextViewText(R.id.tvToday, "Today is: " + df.format(new Date()));
			
		if (Arrays.asList(suspendedDates).contains(df.format(Calendar.getInstance(Locale.US).getTime()))) {
			views.setTextViewText(R.id.tvParkStatus, "Alternate Parking is Suspended");
			views.setTextColor(R.id.tvParkStatus, Color.WHITE);
			views.setImageViewResource(R.id.ivCal, R.drawable.suspended);
		}
		else {
			views.setTextViewText(R.id.tvParkStatus, "Alternate Parking is Not Suspended");
			views.setTextColor(R.id.tvParkStatus, Color.YELLOW);
			views.setImageViewResource(R.id.ivCal, R.drawable.notsuspended);
		}

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


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