// 点击事件 @SuppressLint("NewApi") @Override public void onClick(View v) { switch (v.getId()) { case R.id.common_back: finish(); break; case R.id.rb_notification: isFalg = 0; page = 1; if (adapter_m.getmMessage_list() != null) adapter_m.getmMessage_list().clear(); adapter_m.notifyDataSetChanged(); mPullList.getRefreshableView().setAdapter(adapter_n); setRadioButton(); mNotification.setBackground(getResources().getDrawable(R.drawable.rd_message_l)); mNotification.setTextColor(getResources().getColor(R.color.white)); getData(); break; case R.id.rb_message: isFalg = 1; page = 1; if (adapter_n.getmMessage_list() != null) adapter_n.getmMessage_list().clear(); adapter_n.notifyDataSetChanged(); mPullList.getRefreshableView().setAdapter(adapter_m); setRadioButton(); mMessage.setBackground(getResources().getDrawable(R.drawable.rd_message_r)); mMessage.setTextColor(getResources().getColor(R.color.white)); getData(); break; default: break; } }
public static void setTaskItemWarningTextView( final Activity activity, final TaskWarning taskWarning, final TextView v) { v.setText(taskWarning.name); if (taskWarning.status == TaskWarning.Status.OPENED) { v.setBackground(activity.getResources().getDrawable(R.drawable.border_textview_bg_red, null)); v.setTextColor(activity.getResources().getColor(R.color.red)); } else { v.setBackground( activity.getResources().getDrawable(R.drawable.border_textview_bg_gray, null)); v.setTextColor(activity.getResources().getColor(R.color.gray1)); } }
private void InstallInterface() { FileUtils mFileUtils = new FileUtils(); if (mFileUtils.isFileExist(Utilities.mRecoveryFileName)) { Utilities.mIslocalDownload = true; btnOperation.setText(getString(R.string.install)); LeftPromptInfo.setText(getString(R.string.Will_upgrade)); Utilities.setViewDisText(RightPromptInfo, getString(R.string.update_notice)); Progresstext.setBackground(getResources().getDrawable(R.drawable.ic_finish_pic)); } else { btnOperation.setText(getString(R.string.Quit)); LeftPromptInfo.setText(getString(R.string.No_update_file)); Utilities.setViewDisText(RightPromptInfo, getString(R.string.No_update_file_Prompt)); Progresstext.setBackground(getResources().getDrawable(R.drawable.ic_error_pic)); } }
@SuppressLint("NewApi") public void handleMessage(Message message) { int listsize = 0; switch (message.what) { case CLICK_TYPE_SHOWLIST: JobManagedAdapter = new CompanyJobManagedAdapter(mContext, viewhandler, mJobEmployList); JobManagedList.setAdapter(JobManagedAdapter); case 1000: JobManagedStruct jmStruct = (JobManagedStruct) message.obj; if (jmStruct != null) getCheckedList(jmStruct); if (mJobManagedList != null) { listsize = mJobManagedList.size(); } if (listsize > 0) { EmploymentBtn.setBackground( getResources().getDrawable(R.drawable.feadback_submit_selsector)); } break; case -1000: JobManagedStruct jmStruct1 = (JobManagedStruct) message.obj; if (jmStruct1 != null) RemoveUnCheckedList(jmStruct1); if (mJobManagedList != null) { listsize = mJobManagedList.size(); } if (listsize <= 0) { EmploymentBtn.setBackgroundColor(getResources().getColor(R.color.darkgray)); } break; } }
public void altTableRow(int alt_row) { int childViewCount = tablelayout.getChildCount(); for (int i = 0; i < childViewCount; i++) { TableRow row = (TableRow) tablelayout.getChildAt(i); for (int j = 0; j < row.getChildCount(); j++) { TextView tv = (TextView) row.getChildAt(j); if (i % alt_row != 0) { tv.setBackground(getResources().getDrawable(R.drawable.alt_row_color)); } else { tv.setBackground(getResources().getDrawable(R.drawable.row_color)); } } } }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) public NumberAddSubView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); /** 最后一个参数:把当前类当作是父View,本质是合为一体 */ View.inflate(context, R.layout.number_add_sub_view, this); btn_sub = (Button) findViewById(R.id.btn_sub); tv_number = (TextView) findViewById(R.id.tv_number); btn_add = (Button) findViewById(R.id.btn_add); // 设置监听事件 btn_sub.setOnClickListener(this); btn_add.setOnClickListener(this); tv_number.setText(getValue() + ""); // 获取属性 TintTypedArray tt = TintTypedArray.obtainStyledAttributes(context, attrs, R.styleable.NumberAddSubView); int value = tt.getInt(R.styleable.NumberAddSubView_value, 0); if (value > 0) { setValue(value); } int minValue = tt.getInt(R.styleable.NumberAddSubView_minValue, 0); if (minValue > 0) { setMinValue(minValue); } int maxValue = tt.getInt(R.styleable.NumberAddSubView_maxValue, 0); if (maxValue > 0) { setMaxValue(maxValue); } Drawable btnSubBackground = tt.getDrawable(R.styleable.NumberAddSubView_btnSubBackground); if (btnSubBackground != null) { btn_sub.setBackground(btnSubBackground); } Drawable btnAddBackground = tt.getDrawable(R.styleable.NumberAddSubView_btnAddBackground); if (btnAddBackground != null) { btn_add.setBackground(btnAddBackground); } Drawable textviewBackground = tt.getDrawable(R.styleable.NumberAddSubView_textviewBackground); if (textviewBackground != null) { tv_number.setBackground(textviewBackground); } }
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if (requestCode == FILECHOOSER_RESULTCODE) { // found this from StackOverflow if (null == mUploadMessage) return; Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null; } else { // -----------I wrote this code below this line---------------------------------- jpegData = intent.getExtras().getByteArray("image"); Bitmap img = BitmapFactory.decodeByteArray(jpegData, 0, jpegData.length); Drawable d = new BitmapDrawable(img); profilePicture.setBackground(d); } }
@Override public View getView() throws ElementFailureException { if (elementView != null) return elementView; LinearLayout v = (LinearLayout) LayoutInflater.from(Utils.mainActivity) .inflate(R.layout.template_livelabel, this.layout, false); assert v != null; elementView = v; /** Nesting another element's view in our own for title and description. */ LinearLayout descriptionFrame = (LinearLayout) v.findViewById(R.id.SLiveLabel_descriptionFrame); if (titleObj != null) { TextView titleView = (TextView) titleObj.getView(); titleView.setBackground(null); descriptionFrame.addView(titleView); } if (descriptionObj != null) descriptionFrame.addView(descriptionObj.getView()); liveLabel = (TextView) v.findViewById(R.id.SLiveLabel_textView); if (style != null) { if (style.contains("bold") && style.contains("italic")) { liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD_ITALIC); return v; } if (style.contains("bold")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.BOLD); if (style.contains("italic")) liveLabel.setTypeface(liveLabel.getTypeface(), Typeface.ITALIC); } try { liveLabel.setText(Utils.runCommand(command).replace("@n", "\n")); } catch (Exception e) { throw new ElementFailureException(this, e); } return v; }
@Override public View getView(int position, View convertView, ViewGroup parent) { final TextView view = createViewFromResource(position, convertView, parent, R.layout.edit_simple_spinner_item); // We don't want any background on this view. The background would obscure // the spinner's background. view.setBackground(null); // The text color should be a very light hint color when unfocused and empty. When // focused and empty, use a less light hint color. When non-empty, use a dark non-hint // color. if (!LabeledEditorView.this.isEmpty()) { view.setTextColor(mTextColorDark); } else if (LabeledEditorView.this.hasFocus()) { view.setTextColor(mTextColorSecondary); } else { view.setTextColor(mTextColorHintUnfocused); } return view; }
/** * Sets the popup colors, when QuickScroll.TYPE_POPUP is selected as type. * * <p> * * @param backgroundcolor the background color of the TextView * @param bordercolor the background color of the border surrounding the TextView * @param textcolor the color of the text */ @SuppressWarnings("deprecation") @SuppressLint("NewApi") public void setPopupColor( final int backgroundcolor, final int bordercolor, final int borderwidthDPI, final int textcolor, float cornerradiusDPI) { final GradientDrawable popupbackground = new GradientDrawable(); popupbackground.setCornerRadius(cornerradiusDPI * getResources().getDisplayMetrics().density); popupbackground.setStroke( (int) (borderwidthDPI * getResources().getDisplayMetrics().density), bordercolor); popupbackground.setColor(backgroundcolor); if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) mScrollIndicatorText.setBackgroundDrawable(popupbackground); else mScrollIndicatorText.setBackground(popupbackground); mScrollIndicatorText.setTextColor(textcolor); }
/** * Called to create this view * * @param inflater the layout inflater to inflate a layout from system * @param container the container the layout is going to be placed in * @return */ @Override public View onCreateView(LayoutInflater inflater, ViewGroup container) { Context ctx = inflater.getContext(); View view = inflater.inflate(R.layout.navdrawer_item, container, false); ImageView iconView = ButterKnife.findById(view, R.id.icon); TextView titleView = ButterKnife.findById(view, R.id.title); TextView badgeView = ButterKnife.findById(view, R.id.badge); // Set the textResId FontLoader.apply(titleView, Face.ROBOTO_MEDIUM); titleView.setText(textResId); // Set the iconResId, if provided iconView.setVisibility(iconResId > 0 ? View.VISIBLE : View.GONE); if (iconResId > 0) iconView.setImageResource(iconResId); // configure its appearance according to whether or not it's selected titleView.setTextColor( selected ? UIUtils.getColorAttr(ctx, R.attr.colorPrimary) : ctx.getResources().getColor(R.color.navdrawer_text_color)); iconView.setColorFilter( selected ? UIUtils.getColorAttr(ctx, R.attr.colorPrimary) : ctx.getResources().getColor(R.color.navdrawer_icon_tint)); // Setup the badge view if (badge != null) { Drawable badgeBackground = DrawableCompat.wrap(ctx.getResources().getDrawable(R.drawable.badge)); DrawableCompat.setTint(badgeBackground, badge.getColor()); badgeView.setBackground(badgeBackground); badgeView.setTextColor(badge.getTextColor()); badgeView.setText(badge.getText()); badgeView.setVisibility(View.VISIBLE); } return view; }
@Override @SuppressWarnings("unchecked") public View getView(int position, View convertView, ViewGroup parent) { TextView textView; if (convertView == null) { convertView = View.inflate(mContext, R.layout.spinner_list_item, null); textView = (TextView) convertView.findViewById(R.id.tv_tinted_spinner); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { textView.setBackground(ContextCompat.getDrawable(mContext, R.drawable.selector)); } convertView.setTag(new ViewHolder(textView)); } else { textView = ((ViewHolder) convertView.getTag()).textView; } textView.setText(getItem(position).toString()); return convertView; }
private TextView getNumberButton(int resourceText, int number) { LayoutParams params = new LayoutParams(ruler.getW(31), ruler.getW(23)); StateListDrawable states = new StateListDrawable(); states.addState( new int[] {android.R.attr.state_pressed}, new ColorDrawable(ColorTable._D5D5D5)); states.addState( new int[] {android.R.attr.state_focused}, new ColorDrawable(ColorTable._D5D5D5)); states.addState( new int[] {}, new ColorDrawable(designSpec.getPrimaryColors().getBackgroundOne())); TextView v = new TextView(getContext()); v.setId(RandomId.get()); v.setLayoutParams(params); v.setBackground(states); v.setGravity(Gravity.CENTER); v.setText(resourceText); v.setTag(number); v.setTextColor(ColorTable._666666); styleLargeButton.style(v); return v; }
@Override public View getView(final int position, View convertView, ViewGroup arg2) { convertView = mInflater.inflate(R.layout.robot_detail_forceopen_gvitem, null); TextView gv_item_tv = (TextView) convertView.findViewById(R.id.gv_item_tv); gv_item_tv.setText("" + (position + 1)); if (hasList.contains("" + position)) { if (selectList.contains(position + "")) { gv_item_tv.setBackgroundResource(R.drawable.rangle_green); gv_item_tv.setTextColor(context.getResources().getColor(R.color.text_white)); } else { gv_item_tv.setTextColor(context.getResources().getColor(R.color.text_grey)); gv_item_tv.setBackgroundResource(R.drawable.rangle_grey); } } else { gv_item_tv.setBackground(null); gv_item_tv.setTextColor(context.getResources().getColor(R.color.text_white)); gv_item_tv.setText(""); } gv_item_tv.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { if (!hasList.contains(position + "")) { return; } if (selectList.contains(position + "")) { selectList.remove(position + ""); } else { selectList.add(position + ""); } notifyDataSetChanged(); } }); return convertView; }
/** * Set the style of TextView according to the status of a task * * @param context * @param status * @param task */ public static void setTaskStatusForTextView(Context context, TextView status, Task task) { status.setText(Task.getTaskStatusString(context, task)); switch (task.status) { case IN_REVIEW: status.setTextColor(context.getResources().getColor(R.color.task_card_status_text_color)); status.setBackgroundResource(R.drawable.task_card_status_in_review_background); break; case WIP: status.setTextColor(context.getResources().getColor(R.color.task_card_status_text_color)); status.setBackgroundResource(R.drawable.task_card_status_wip_background); break; case PENDING: status.setTextColor(context.getResources().getColor(R.color.task_card_status_text_color)); status.setBackgroundResource(R.drawable.task_card_status_pending_background); break; case UNCLAIMED: status.setTextColor(context.getResources().getColor(R.color.task_card_status_text_color)); status.setBackgroundResource(R.drawable.task_card_status_unclaimed_background); break; case WARNING: status.setTextColor(context.getResources().getColor(R.color.task_card_status_text_color)); status.setBackgroundResource(R.drawable.task_card_status_warning_background); break; case DONE: status.setTextColor( context.getResources().getColor(R.color.task_card_status_done_text_color)); status.setBackground(null); break; } }
@SuppressLint("NewApi") @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub Resources resource = context.getResources(); if (event.getAction() == MotionEvent.ACTION_UP) { if (R.id.copy_btn == v.getId()) { Drawable drawable = null; if (bcopyShow && bresendShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); } else if (bcopyShow || bresendShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_normal); } if (drawable != null) { copyBtn.setBackground(drawable); copyBtn.setPadding(0, 13, 0, 8); } } else if (R.id.resend_btn == v.getId()) { Drawable drawable = null; if (bcopyShow && bresendShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); } else if (bcopyShow || bresendShow) { if (bspeakerShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); } else { drawable = resource.getDrawable(R.drawable.tt_bg_popup_normal); } } if (drawable != null) { resendBtn.setBackground(drawable); resendBtn.setPadding(0, 13, 0, 8); } } else if (R.id.speaker_btn == v.getId()) { Drawable drawable = null; if (bresendShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); } else if (bspeakerShow) { drawable = resource.getDrawable(R.drawable.tt_bg_popup_normal); } if (drawable != null) { speakerBtn.setBackground(drawable); speakerBtn.setPadding(0, 13, 0, 8); } } } else { if (R.id.copy_btn == v.getId()) { Drawable drawableResend = null; Drawable drawableCopy = null; if (bcopyShow && bresendShow) { drawableCopy = resource.getDrawable(R.drawable.tt_bg_popup_left_pressed); drawableResend = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); } else if (bcopyShow || bresendShow) { drawableCopy = resource.getDrawable(R.drawable.tt_bg_popup_pressed); } if (drawableCopy != null) { copyBtn.setBackground(drawableCopy); copyBtn.setPadding(0, 13, 0, 8); } if (drawableResend != null) { resendBtn.setBackground(drawableResend); resendBtn.setPadding(0, 13, 0, 8); } } else if (R.id.resend_btn == v.getId()) { Drawable drawableCopy = null; Drawable drawableResend = null; Drawable drawableSpeaker = null; if (bcopyShow && bresendShow) { drawableCopy = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); drawableResend = resource.getDrawable(R.drawable.tt_bg_popup_right_pressed); } else if (bcopyShow || bresendShow) { if (bspeakerShow) { drawableSpeaker = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); drawableResend = resource.getDrawable(R.drawable.tt_bg_popup_right_pressed); } else { drawableResend = resource.getDrawable(R.drawable.tt_bg_popup_pressed); } } if (drawableResend != null) { resendBtn.setBackground(drawableResend); resendBtn.setPadding(0, 13, 0, 8); } if (drawableCopy != null) { copyBtn.setBackground(drawableCopy); copyBtn.setPadding(0, 13, 0, 8); } if (drawableSpeaker != null) { speakerBtn.setBackground(drawableSpeaker); speakerBtn.setPadding(0, 13, 0, 8); } } else if (R.id.speaker_btn == v.getId()) { // Drawable drawableCopy = null; Drawable drawableResend = null; Drawable drawableSpeaker = null; if (bresendShow && bspeakerShow) { drawableSpeaker = resource.getDrawable(R.drawable.tt_bg_popup_left_pressed); drawableResend = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); } else if (bspeakerShow) { drawableSpeaker = resource.getDrawable(R.drawable.tt_bg_popup_pressed); } if (drawableResend != null) { resendBtn.setBackground(drawableResend); resendBtn.setPadding(0, 13, 0, 8); } if (drawableSpeaker != null) { speakerBtn.setBackground(drawableSpeaker); speakerBtn.setPadding(0, 13, 0, 8); } } } return false; }
private void initLayout() { textView = new TextView(getContext()); textView.setGravity(Gravity.CENTER); matchParentParams = new AbsListView.LayoutParams((int) CellConfig.cellWidth, (int) CellConfig.cellHeight); switch (MarkStyle.current) { case MarkStyle.DEFAULT: this.setLayoutParams(matchParentParams); this.setOrientation(HORIZONTAL); textView.setTextColor(Color.WHITE); circleDrawable = new ShapeDrawable(new OvalShape()); circleDrawable.getPaint().setColor(MarkStyle.color); this.setPadding(20, 20, 20, 20); textView.setLayoutParams( new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, (float) 1.0)); textView.setBackground(circleDrawable); this.addView(textView); return; case MarkStyle.BACKGROUND: this.setLayoutParams(matchParentParams); this.setOrientation(HORIZONTAL); textView.setTextColor(Color.WHITE); circleDrawable = new ShapeDrawable(new OvalShape()); circleDrawable.getPaint().setColor(MarkStyle.color); this.setPadding(20, 20, 20, 20); textView.setLayoutParams( new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, (float) 1.0)); textView.setBackground(circleDrawable); this.addView(textView); return; case MarkStyle.DOT: this.setLayoutParams(matchParentParams); this.setOrientation(VERTICAL); textView.setLayoutParams( new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 0, (float) 2.0)); this.addView(new PlaceHolderVertical(getContext())); this.addView(textView); this.addView(new Dot(getContext())); return; case MarkStyle.RIGHTSIDEBAR: this.setLayoutParams(matchParentParams); this.setOrientation(HORIZONTAL); textView.setLayoutParams( new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, (float) 3.0)); this.addView(new PlaceHolderHorizontal(getContext())); this.addView(textView); PlaceHolderHorizontal barRight = new PlaceHolderHorizontal(getContext()); barRight.setBackgroundColor(MarkStyle.color); this.addView(barRight); return; case MarkStyle.LEFTSIDEBAR: this.setLayoutParams(matchParentParams); this.setOrientation(HORIZONTAL); textView.setLayoutParams( new LayoutParams(0, ViewGroup.LayoutParams.MATCH_PARENT, (float) 3.0)); PlaceHolderHorizontal barLeft = new PlaceHolderHorizontal(getContext()); barLeft.setBackgroundColor(MarkStyle.color); this.addView(barLeft); this.addView(textView); this.addView(new PlaceHolderHorizontal(getContext())); return; default: throw new IllegalArgumentException("Invalid Mark Style Configuration!"); } }
@Override public View getView() throws ElementFailureException { if (elementView != null) return elementView; LinearLayout v = new LinearLayout(Utils.mainActivity); v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); v.setOrientation(LinearLayout.VERTICAL); elementView = v; /** Nesting another element's view in our own for title and description. */ LinearLayout descriptionFrame = new LinearLayout(Utils.mainActivity); LayoutParams dfl = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); descriptionFrame.setOrientation(LinearLayout.VERTICAL); final int leftMargin = (int) (2 * Utils.density + 0.5f); dfl.setMargins(leftMargin, 0, 0, 0); descriptionFrame.setLayoutParams(dfl); elementView.addView(descriptionFrame); if (titleObj != null) { TextView titleView = (TextView) titleObj.getView(); titleView.setBackground(null); descriptionFrame.addView(titleView); } if (descriptionObj != null) descriptionFrame.addView(descriptionObj.getView()); textView = new TextView(Utils.mainActivity); textView.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); textView.setTextColor(Color.parseColor("#AAAAAA")); textView.setId(tv_id); elementView.addView(textView); v.setOnLongClickListener(this); textView.setOnLongClickListener(this); elementFrame = new LinearLayout(Utils.mainActivity); elementFrame.setLayoutParams( new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); elementFrame.setOrientation(LinearLayout.VERTICAL); selectorFrame = new FrameLayout(Utils.mainActivity); LayoutParams sfl = new LayoutParams((int) (15 * Utils.density + 0.5f), LayoutParams.MATCH_PARENT); int margin = (int) (Utils.density + 0.5f); sfl.setMargins(0, margin, 0, margin); selectorFrame.setLayoutParams(sfl); selectorFrame.setBackgroundColor(Color.DKGRAY); selectorFrame.setVisibility(View.GONE); elementFrame.addView(selectorFrame); elementFrame.addView(v); elementView = elementFrame; String initialLive = getLiveValue(); if (getStoredValue() == null) { Utils.db.setValue(command, initialLive); stored = lastLive; } lastEdit = lastLive; if (original == null) original = lastLive; textView.setOnClickListener(this); textView.setText(lastLive.toString()); valueCheck(); return elementView; }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onBindViewHolder(final ViewHolder viewHolder, final int position) { final PackageOneKeyBuyBeanNew ratings = mratings.get(position); // 设置图片bufen // GlideUtil.display(context, viewHolder.iv_imgurl, ratings.getSku_image(), // GlideOptionsFactory.get(GlideOptionsFactory.Type.RADIUS)); viewHolder.iv_imgurl.setTagText(ratings.getSpeed()); viewHolder.tv_content1.setText(ratings.getSku_title()); viewHolder.tv_content2.setText(ratings.getSku_notice()); if (ratings.getShop_info() != null) { viewHolder.tv_content3.setText(ratings.getShop_info().getShop_name()); } else { viewHolder.tv_content3.setText(""); } viewHolder.layou231.removeAllViews(); // 设置首免部分 if (ratings.getCoupon_list() != null && ratings.getCoupon_list().size() > 0) { viewHolder.ll_pingjia1.setVisibility(View.VISIBLE); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; // 加载TextView for (int i = 0; i < ratings.getCoupon_list().size(); i++) { // Pingjia ping = pingjia[i]; Coupon_listBeanNew tag = ratings.getCoupon_list().get(i); LinearLayout ll = (LinearLayout) View.inflate(context, R.layout.tag_item, null); TextView tv1 = (TextView) ll.findViewById(R.id.tv_content_tag1); TextView tv2 = (TextView) ll.findViewById(R.id.tv_content_tag2); // 第一部分 tv1.setTextSize(15.0f); tv1.setText(tag.getCoupon_str()); if (i % 2 == 0) { params.setMargins(0, 10, 10, 0); } tv1.setBackground(context.getResources().getDrawable(R.drawable.hongbao_color)); tv1.setTag(false); tv1.setPadding(5, 1, 5, 1); // context.getResources().getColor(R.color.orange_color) tv1.setTextColor( context.getResources().getColor(R.color.white)); // Color.parseColor("#FFFFFF") // tag.getCoupon_color().substring(1)= #FFFFFF tag.getCoupon_color().substring(1) int color = Integer.parseInt( tag.getCoupon_color().substring(1), 16); // tag.getCoupon_color().substring(1) FF5001 color = 0xFF000000 + color; tv1.getBackground() .setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN)); // 第二部分 tv2.setTextSize(12.0f); tv2.setText(tag.getCoupon_info()); if (i % 2 == 0) { params.setMargins(0, 10, 10, 0); } tv2.setTag(false); tv2.setPadding(5, 1, 15, 1); // context.getResources().getColor(R.color.orange_color) tv2.setTextColor( context.getResources().getColor(R.color.gray)); // Color.parseColor("#FFFFFF") viewHolder.layou231.addView(ll, params); } } else { viewHolder.ll_pingjia1.setVisibility(View.INVISIBLE); } viewHolder.tv_content5.setText("¥" + formatPrice2(ratings.getSku_price())); viewHolder.tv_content6.setText(ratings.getSku_pki()); tags = ratings.getTag_list(); // TagBean viewHolder.layou23.removeAllViews(); if (tags != null) { viewHolder.ll_pingjia.setVisibility(View.VISIBLE); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.gravity = Gravity.CENTER_VERTICAL; // 加载TextView for (int i = 0; i < tags.size(); i++) { TagBeanNew tag = tags.get(i); tvNav = new TextView(context); tvNav.setTextSize(15.0f); tvNav.setText(tag.getTag_name()); if (i % 2 == 0) { params.setMargins(0, 10, 10, 0); } tvNav.setBackgroundResource(R.drawable.tag_color); tvNav.setTag(false); tvNav.setTextColor( context.getResources().getColor(R.color.orange_color)); // Color.parseColor("#FFFFFF") viewHolder.layou23.addView(tvNav, params); } } else { viewHolder.ll_pingjia.setVisibility(View.GONE); } // 如果设置了回调,则设置点击事件 if (mOnItemClickLitener != null) { viewHolder.itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { mOnItemClickLitener.onItemClick(viewHolder.itemView, position); } }); } }
public static void setTaskItemWarningTextView( final Activity activity, final Task item, final TextView v, boolean hasClickListener) { if (item.taskWarnings.size() == 0) { v.setVisibility(View.GONE); return; } String displayTxt = ""; int txtColor; Drawable background; int unSolvedCount = item.getUnSolvedWarningCount(); int solvedCount = item.taskWarnings.size() - item.getUnSolvedWarningCount(); if (unSolvedCount > 1) { displayTxt = activity.getResources().getString(R.string.overview_display_warning_txt, unSolvedCount); } else if (solvedCount > 1) { displayTxt = activity.getResources().getString(R.string.overview_display_warning_txt, solvedCount); } else { TaskWarning tmp = null; for (TaskWarning taskWarning : item.taskWarnings) { if (tmp == null) { tmp = taskWarning; } else { if (tmp.status == TaskWarning.Status.CLOSED && taskWarning.status == TaskWarning.Status.OPENED) { tmp = taskWarning; } } displayTxt = tmp.name; } } if (unSolvedCount > 0) { txtColor = activity.getResources().getColor(R.color.red); background = activity.getResources().getDrawable(R.drawable.border_textview_bg_red, null); } else { txtColor = activity.getResources().getColor(R.color.gray1); background = activity.getResources().getDrawable(R.drawable.border_textview_bg_gray, null); } v.setTextColor(txtColor); v.setText(displayTxt); v.setBackground(background); if (hasClickListener && item.taskWarnings.size() > 1) { v.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { View view = activity .getLayoutInflater() .inflate(R.layout.warning_list_container_layout, null); LinearLayout root = (LinearLayout) view.findViewById(R.id.warning_list_container); for (TaskWarning taskWarning : item.taskWarnings) { TextView tv = (TextView) activity .getLayoutInflater() .inflate(R.layout.warning_textview_layout, null); setTaskItemWarningTextView(activity, taskWarning, tv); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = (int) activity.getResources().getDimension(R.dimen.ov_warning_margin_horizontal); params.rightMargin = (int) activity.getResources().getDimension(R.dimen.ov_warning_margin_horizontal); root.addView(tv, params); } final PopupWindow popup = new PopupWindow( view, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); popup.setBackgroundDrawable(new BitmapDrawable()); popup.setOutsideTouchable(true); int[] locations = new int[2]; v.getLocationOnScreen(locations); view.measure( View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED)); popup.showAtLocation( v, Gravity.NO_GRAVITY, locations[0] + v.getMeasuredWidth() - view.getMeasuredWidth(), locations[1] - view.getMeasuredHeight()); } }); } }
@SuppressLint("NewApi") public void show(View item, int type, boolean bResend, boolean bSelf) { if (mPopup == null || mPopup.isShowing()) { return; } boolean showTop = true; int[] location = new int[2]; item.getLocationOnScreen(location); // 默认在item上面弹出 if (location[1] - mParentTop /* - mHeight */ <= 0) { // showTop = false; } else { // 如果不是在最顶部,显示的距离要上移10 location[1] = location[1] - 10; } if (type == 2) { speakerBtn.setVisibility(View.VISIBLE); if (MessageActivity.getAudioMode() == SysConstant.AUDIO_PLAY_MODE_NORMAL) { speakerBtn.setText(R.string.call_mode); } else { speakerBtn.setText(R.string.speaker_mode); } bspeakerShow = true; } else { speakerBtn.setVisibility(View.GONE); bspeakerShow = false; } if (bResend && bSelf) { resendBtn.setVisibility(View.VISIBLE); bresendShow = true; if (type == 1) { copyBtn.setVisibility(View.VISIBLE); bcopyShow = true; } else { copyBtn.setVisibility(View.GONE); bcopyShow = false; } } else if (!bResend && bSelf) { resendBtn.setVisibility(View.GONE); bresendShow = false; if (type != 2 && type != 3) { copyBtn.setVisibility(View.VISIBLE); bcopyShow = true; } else if (type != 2) { copyBtn.setVisibility(View.GONE); bcopyShow = false; return; } else { copyBtn.setVisibility(View.GONE); bcopyShow = false; } } else { if (type != 2 && type != 3) { copyBtn.setVisibility(View.VISIBLE); bcopyShow = true; } else if (type != 2) { copyBtn.setVisibility(View.GONE); bcopyShow = false; return; } else { copyBtn.setVisibility(View.GONE); bcopyShow = false; } } Resources resource = context.getResources(); if (bcopyShow && bresendShow) { // int nWidth = (int) resource // .getDimension(R.dimen.message_item_popup_width_double_short); mWidth = (int) resource.getDimension(R.dimen.message_item_popup_width_double_short); mPopup.setWidth(mWidth); Drawable bgLeft = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); copyBtn.setBackground(bgLeft); copyBtn.setPadding(0, 13, 0, 8); Drawable bgRight = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); resendBtn.setBackground(bgRight); resendBtn.setPadding(0, 13, 0, 8); } else if (bcopyShow || bresendShow) { if (bspeakerShow) { // int nWidth = (int) resource // .getDimension(R.dimen.message_item_popup_width_double_long); mWidth = (int) resource.getDimension(R.dimen.message_item_popup_width_double_long); mPopup.setWidth(mWidth); Drawable bgLeft = resource.getDrawable(R.drawable.tt_bg_popup_left_nomal); speakerBtn.setBackground(bgLeft); Drawable bgRight = resource.getDrawable(R.drawable.tt_bg_popup_right_nomal); speakerBtn.setPadding(0, 13, 0, 8); resendBtn.setBackground(bgRight); resendBtn.setPadding(0, 13, 0, 8); } else { // int nWidth = (int) resource // .getDimension(R.dimen.message_item_popup_width_single_short); mWidth = (int) resource.getDimension(R.dimen.message_item_popup_width_single_short); mPopup.setWidth(mWidth); Drawable bgNormal = resource.getDrawable(R.drawable.tt_bg_popup_normal); copyBtn.setBackground(bgNormal); resendBtn.setBackground(bgNormal); copyBtn.setPadding(0, 13, 0, 8); resendBtn.setPadding(0, 13, 0, 8); } } else if (bspeakerShow) { // int nWidth = (int) resource // .getDimension(R.dimen.message_item_popup_width_single_long); mWidth = (int) resource.getDimension(R.dimen.message_item_popup_width_single_long); mPopup.setWidth(mWidth); Drawable bgNormal = resource.getDrawable(R.drawable.tt_bg_popup_normal); speakerBtn.setBackground(bgNormal); speakerBtn.setPadding(0, 13, 0, 8); } else { return; } if (showTop) { if (location[1] - mParentTop /* - mHeight */ > 0) { mPopup.showAtLocation( item, Gravity.NO_GRAVITY, location[0] + (item.getWidth() / 2 - mWidth / 2), location[1] - mHeight); } else { mPopup.showAtLocation( item, Gravity.NO_GRAVITY, location[0] + (item.getWidth() / 2 - mWidth / 2), 0 + mHeight / 2); } } else { // TODO: 在下面弹出的时候需要翻转背景 mPopup.showAtLocation( item, Gravity.NO_GRAVITY, location[0] + (item.getWidth() / 2 - mWidth / 2), location[1] + item.getHeight()); } }
private void displayTextFieldAsReadOnly(TextView textField) { textField.setInputType(0); textField.setFocusable(false); textField.setBackground(null); }
private void show_battery_dialog() { btnOperation.setText(getString(R.string.Quit)); Progresstext.setBackground(getResources().getDrawable(R.drawable.ic_error_pic)); LeftPromptInfo.setText(getString(R.string.battery_low)); Utilities.setViewDisText(RightPromptInfo, getString(R.string.battery_notify)); }