Karthik Kolanji Karthik Kolanji - 1 year ago 228
Android Question

compulsory asterisk in textview android

I using the fields which are mandatory , for this I am using

which includesred colored asterisk

My output: click link!

Required output : click link!

I tried to modify the code,but didn't got expected result

public void setCompulsoryAsterisk(){

txt_name="Name : ";
String colored="*";
SpannableStringBuilder strBuilder=new SpannableStringBuilder();
int start=strBuilder.length();
int end=strBuilder.length();
strBuilder.setSpan(new ForegroundColorSpan(Color.RED), start, end, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

Answer Source
String txt_name="Name ";
String colored="*";
String colon = " : ";

after you append string colored, append string colon after it. Voila.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download