阅读更多
package wq.test;import android.app.Activity;import android.graphics.Color;import android.os.Bundle;import android.text.SpannableString;import android.text.Spanned;import android.text.method.LinkMovementMethod;import android.text.style.ClickableSpan;import android.view.View;import android.widget.TextView;public class AndroidTestActivity extends Activity{private final String stringToShow = "test,test,test,test,test,test,test,test,test,test,test,test," +"test,test,test,test,test,test,test,test,test,test,test,test,test,test" +",test,test,test,test,test,test,test,test,test,test,test,test,test,test" +"testtest test test...";private final String readMore = "Read More";@Overridepublic void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);this.setContentView(R.layout.main);TextView tv = (TextView) this.findViewById(R.id.textView);ClickableSpan clickableSpan = new ClickableSpan() {@Overridepublic void onClick(View widget) {if (widget instanceof TextView) {((TextView) widget).setText(stringToShow + stringToShow);}}};setClickableSpanForTextView(tv, clickableSpan, stringToShow + readMore, stringToShow.length(), stringToShow.length() + readMore.length());}/** *  * @param tv TextView * @param clickableSpan Click event * @param text Text to show * @param start Start point in text for handle click event * @param end End point in text for handle click event */private void setClickableSpanForTextView(TextView tv, ClickableSpan clickableSpan, String text, int start, int end) {SpannableString sp = new SpannableString(text);sp.setSpan(clickableSpan, start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);tv.setText(sp);tv.setLinkTextColor(Color.RED);tv.setMovementMethod(LinkMovementMethod.getInstance());tv.setFocusable(false);tv.setClickable(false);tv.setLongClickable(false);}}

更多相关文章

  1. OpenGL ES教程V之更多3D模型(原文对照)
  2. android facebook authorize 时禁止调用facebook app
  3. Android(安卓)源码阅读之SMS
  4. android 弹出软盘
  5. 获取Android(安卓)Device的信息
  6. The Saygus VPhone V1 clears FCC, Will this be Verizon’s nex
  7. Porting Android
  8. The Saygus VPhone V1 clears FCC, Will this be Verizon’s nex
  9. android facebook authorize 时禁止调用facebook app

随机推荐

  1. 冷月手撕408之操作系统(23)-输入输出管理
  2. 冷月手撕408之操作系统(12)-内存的分配与
  3. 冷月手撕408之数据结构(4)-链表
  4. 冷月手撕408之操作系统(21)-文件的实现
  5. 冷月手撕408之操作系统(4)-操作系统的运
  6. 冷月手撕408之操作系统(21)-文件的共享与
  7. 冷月手撕408之操作系统(12)-内存管理基础
  8. 冷月手撕408之操作系统(3)-操作系统的发
  9. 冷月手撕408之操作系统(2)-操作系统的基
  10. PHP变量的知识点