Just a quick question:
Do you know why i can do that:
pnrCode = (TextView)findViewById(R.id.pnr);
SpannableString pnrContent = new SpannableString("PNR: ");
pnrContent.setSpan(new UnderlineSpan(), 0, pnrContent.length(), 0);
pnrCode.setText(pnrContent + BookingSettings.getBookingSegment().substring(0, 6));
The text is not underlined.
Whereas, if i do only that:
pnrCode = (TextView)findViewById(R.id.pnr);
SpannableString pnrContent = new SpannableString("PNR: ");
pnrContent.setSpan(new UnderlineSpan(), 0, pnrContent.length(), 0);
pnrCode.setText(pnrContent);
The text is underlined.
I have to create two textview ?
Do you know another solution ?
Any help is appreciated 😉
No.
pnrContent + BookingSettings.getBookingSegment().substring(0, 6)is probably going to give you aStringback, as I believe the+operator will convert both sides toStringobjects, then perform the concatenation. Hence, you will lose your formatting.Instead, use
new SpannableString("PNR: "+ BookingSettings.getBookingSegment().substring(0, 6));, and set the length of theUnderlineSpanas needed.