本文整理汇总了Java中android.widget.RemoteViews.setTextViewCompoundDrawables方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteViews.setTextViewCompoundDrawables方法的具体用法?Java RemoteViews.setTextViewCompoundDrawables怎么用?Java RemoteViews.setTextViewCompoundDrawables使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.RemoteViews
的用法示例。
在下文中一共展示了RemoteViews.setTextViewCompoundDrawables方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}