字符串是
Or Login to Place your Order
我想要Login
不同颜色的单词加下划线。还需要click event
字
Login
我想用单TextView
来做。我可以使用单TextView
吗?
答案 0 :(得分:1)
强调特定字词......
TextView t = (TextView) findViewById(R.id.textview);
t.setPaintFlags(t.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
t.setText("Underline Text");
以下是您要求的example
答案 1 :(得分:0)
我得到了答案
String orLoginString = "Or Login to Place your Order";
SpannableString redSpannable= new SpannableString(orLoginString);
ClickableSpan clickableSpan = new ClickableSpan()
{
@Override
public void onClick(View textView) {
//Your code onclick of underline string
}
@Override
public void updateDrawState(TextPaint ds) {
// TODO Auto-generated method stub
super.updateDrawState(ds);
//You change the color of underline string.
//You can make underline visible or invisible
}
};
redSpannable.setSpan(clickableSpan, 3, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
yourtextview.setText(redSpannable);
loginSelectionFirstTimeLaunching.setMovementMethod(LinkMovementMethod.getInstance());