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


Java RemoteViews.setTextViewCompoundDrawables方法代碼示例

本文整理匯總了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;
  }
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:74,代碼來源:BigbangNotification.java


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