需要格式化几个textview像一个又一个独特的文本块,有没有办法实现这个?Android:多个textview像单个文本
这样
__________________________
| |
| |
| aaaaaa bbbbbbbbbbbbbbb |
| bbbbbbbbbb cccccc dddd |
| ddddddddddddd. |
| |
我不能把TextView的一个LinearLayout中,因为我会得到这样的效果:
__________________________
| |
| |
| aaaaaa bbbbbbbbbbbbbbb |
| bbbbbbbbbb |
| |
| |
什么想法?
更新:更新与SPANNABLES
String[] testString = { "this is a test ", "for testing click in different region", "of the textview"};
LinearLayout linear = new LinearLayout(this);
TextView textview = new TextView(this);
textview.setMovementMethod(LinkMovementMethod.getInstance());
SpannableStringBuilder builder = new SpannableStringBuilder();
int start = 0;
int end = 0;
for (String span : testString) {
start = end == 0 ? end : end + 1;
end = start + span.length();
final String spanned = span;
builder.append(span);
builder.setSpan(new ClickableSpan() {
@Override
public void onClick(View widget) {
Log.e("Clicked on:", spanned);
}
}, start, end, 0);
Log.e("TEST", span);
}
textview.append(builder);
linear.addView(textview);
setContentView(linear);
2013-10-23
CLucera