Tuesday, 15 June 2010

android - Perform StringBuilder setText method and ExpendableTextView setText method with the same holder -



android - Perform StringBuilder setText method and ExpendableTextView setText method with the same holder -

based on reply given on post,

android - expandable textview animation

i want able utilize function `

holder.expandabletextview.settext(wallcontent); spannablestringbuilder ssb = sharefoliospannablehandler.getspannablestringbuilder(context, wallcontent, currentwall.persontagged, currentwall.companytagged); holder.expandabletextview.setmovementmethod(linkmovementmethod.getinstance()); holder.expandabletextview.settext(ssb);

`

this sharefoliospannablehandler class `

public class sharefoliospannablehandler { public static spannablestringbuilder getspannablestringbuilder(final context context, string text, list<account> persons, list<company> companies) { spannablestringbuilder ssb = new spannablestringbuilder(text); if (persons.size() != 0) { (int = 0; < persons.size(); i++) { final business relationship person = persons.get(i); final string personname = persons.get(i).firstname; if (text.contains(personname)) { int start = text.indexof(personname) - 1; int end = start + personname.length() + 1; ssb.setspan(new stylespan(typeface.bold), start, end, spannable.span_exclusive_exclusive); ssb.setspan(new foregroundcolorspan(color.blue), start, end, spannable.span_exclusive_exclusive); ssb.setspan(new clickablespan() { @override public void onclick(view v) { // todo auto-generated method stub intent intent = new intent(context, loaduserwallactivity.class); intent.putextra(loaduserwallactivity.tag, person); context.startactivity(intent); } }, start, end, spannable.span_exclusive_exclusive); } } } if (companies.size() != 0) { (int = 0 ; < companies.size() ; i++) { final company company = companies.get(i); final string companycode = companies.get(i).companycode; if (text.contains(companycode)) { int start = text.indexof(companycode) - 1; int end = start + companycode.length() + 1; ssb.setspan(new stylespan(typeface.bold), start, end, spannable.span_exclusive_exclusive); ssb.setspan(new foregroundcolorspan(color.blue), start, end, spannable.span_exclusive_exclusive); ssb.setspan(new clickablespan() { @override public void onclick(view v) { intent intent = new intent(context, companyactivity.class); bundle b = new bundle(); b.putserializable("company", company); intent.putextras(b); context.startactivity(intent); } }, start, end, spannable.span_exclusive_exclusive); } } } homecoming ssb; } } `

i having issues expendabletextview holder has settext how include stringbuilder function giving me problems. if run shown above, while create expandable textview, doesnt peform should done stringbuilder in terms of links or tags.

does have clue on how bring together both functions together?

thanks kingsley

i found out issue. needed homecoming output of stringbuilder in expendabletextview instead of this

holder.expandabletextview.settext(wallcontent); spannablestringbuilder ssb = sharefoliospannablehandler.getspannablestringbuilder(context, wallcontent, currentwall.persontagged, currentwall.companytagged); holder.expandabletextview.setmovementmethod(linkmovementmethod.getinstance()); holder.expandabletextview.settext(ssb);

i did

holder.expandabletextview.settext(wallcontent); holder.expandabletextview.setmovementmethod(linkmovementmethod.getinstance()); holder.expandabletextview.settext(sharefoliospannablehandler.getspannablestringbuilder(context, wallcontent, currentwall.persontagged, currentwall.companytagged));

worked me.

android textview stringbuilder expandable

No comments:

Post a Comment