TextView执行click功能:
借用SpannableString或SpannableStringBuilder,两者区别:后者多了修改文本功能
代码片段:
TextView tv = (TextView) findViewById(R.id.textview1);
String t = "显示下个activity";
SpannableString ss = new SpannableString(t);
ss.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
Intent i = new Intent(TextViewActivity.this,CanvasActivity.class);
startActivity(i);
}
}, 0, t.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
tv.setText(ss);
tv.setMovementMethod(LinkMovementMethod.getInstance());