1. 程式人生 > >Android TextView文字區域性變色方法

Android TextView文字區域性變色方法

/** 文字區域性變色 */
	public void agreementLink(int start, int end) {
		SpannableStringBuilder spannable = new SpannableStringBuilder(
				agreementLink.getText().toString());// 用於可變字串
		ForegroundColorSpan span = new ForegroundColorSpan(Color.RED);
		spannable.setSpan(span, start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
		agreementLink.setText(spannable);
	}