We use social software in the process will be more or less like other people's posts point, figure. :
To be able to see the user page is just the name of the user who likes to click on the name, clicking on these names to access the user's home page. We're going to achieve similar results. Go directly to the code.
@Override protected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); TextView Mtextview = (TextView) Rootview.findviewbyid (R.ID.LIKE_TV); Constructs multiple hyperlinks of HTML, with the selected location to get the user name StringBuilder Sbbuilder = new StringBuilder (); for (int i = 0; i < i++) {sbbuilder.append ("username-" + i + ","); The String likeusers = sbbuilder.substring (0, Sbbuilder.lastindexof (",")). ToString (); Mtextview.setmovementmethod (Linkmovementmethod.getinstance ()); Mtextview.settext (Addclickablepart (likeusers), buffertype.spannable); }/** * @param str * @return */private Spannablestringbuilder Addclickablepart (str ing str) {//First likes icon Imagespan span = new Imagespan (getactivity (), r.drawable.umeng_comm_like); spannablestring spanstr = new Spannablestring ("P."); Spanstr.setspan (span, 0, 1, spannable.span_inclusive_exclusive); Spannablestringbuilder SSB = new Spannablestringbuilder (SPANSTR); Ssb.append (str); string[] Likeusers = Str.split (","); if (Likeusers.length > 0) {//last for (int i = 0; i < likeusers.length; i++) { Final String name = Likeusers[i]; Final int start = Str.indexof (name) + spanstr.length (); Ssb.setspan (New Clickablespan () {@Override public void OnClick (View widget) {Toast.maketext (GetView (). GetContext (), name, Toast.length _short). Show (); } @Override public void Updatedrawstate (Textpaint ds) { Super.updatedrawstate (DS); Ds.setcolor (Color.RED); Set the text color//To drop the dash Ds.setunderlinetext (false); }}, start, start + name.length (), 0); }} return Ssb.append ("et" + likeusers.length + "personally liked you."); }//End of AddclickablepartExecution effect:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymjvewzlaxl1/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center "width=" height= "640" style= "border:1px solid black"/>
Copyright notice: This article mr.simple original article, must not be reproduced without consent.
Android for TextView add multiple click Text