void ChageColorOfParticularWordAndClickEvent()
{
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
Log.v("dsdsdssd ", "fdfsdfsdfsdfsdfds sdfdsf ");
Toast.makeText(MainActivity.this, "Hi I am clicked", Toast.LENGTH_LONG).show();
}
@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
ds.setColor(Color.MAGENTA);
// ds.setUnderlineText(false);
}
};
redSpannable.setSpan(clickableSpan, 3, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
yourtextview.setText(redSpannable);
yourtextview.setMovementMethod(LinkMovementMethod.getInstance());
}
{
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
Log.v("dsdsdssd ", "fdfsdfsdfsdfsdfds sdfdsf ");
Toast.makeText(MainActivity.this, "Hi I am clicked", Toast.LENGTH_LONG).show();
}
@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
ds.setColor(Color.MAGENTA);
// ds.setUnderlineText(false);
}
};
redSpannable.setSpan(clickableSpan, 3, 8, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
yourtextview.setText(redSpannable);
yourtextview.setMovementMethod(LinkMovementMethod.getInstance());
}
No comments:
Post a Comment