public void ShowPlaceInfo(Context context, string[] info) { txtAddressFoodiPlaces.Visibility = ViewStates.Visible; txtNameFoodiPlaces.Visibility = ViewStates.Visible; frReviews.Visibility = ViewStates.Visible; lnReviewsTop.Visibility = ViewStates.Visible; txtTopReviewsDetail.Visibility = ViewStates.Visible; lnMoreReviews.Visibility = ViewStates.Gone; txtMore.Visibility = ViewStates.Visible; var score = (float)Math.Round(float.Parse(info[0], System.Globalization.CultureInfo.InvariantCulture) / 2, 2); ratingBar.Value = score; txtScore.Text = score.ToString("0.00"); txtNameFoodiPlaces.Text = info[1]; txtAddressFoodiPlaces.Text = "Địa chỉ: " + info[2] + "."; Random random = new Random(); int randomPosition = random.Next(1, reviews.Count - 1); Review review = reviews[randomPosition]; sfRatingTopReview.Value = review.Score; DisplayCustomRatingBar(sfRatingTopReview); txtTopReviewsDetail.Text = review.Detail; txtTopReviewsDate.Text = review.Date.ToShortDateString() + "\n" + review.Name; SpannableString ss = new SpannableString("Xem Thêm"); var clickableSpan = new MyClickableSpan(); clickableSpan.Click += v => LoadReviews(); ss.SetSpan(clickableSpan, 0, 8, SpanTypes.ExclusiveExclusive); txtMore.TextFormatted = ss; txtMore.MovementMethod = new LinkMovementMethod(); }
void SetTextStyle() { if (base.Control == null) { return; } SpannableString styledString = new SpannableString(base.Control.Text); int counter = 0; foreach (var span in Base.FormattedText.Spans) { var spanText = Base.FormattedText.Spans[counter].Text; var startIndex = base.Control.Text.IndexOf(spanText); var endIndex = startIndex + spanText.Length; if (Base.ClickableIndex == counter) { var clickableSpan = new MyClickableSpan(); TextPaint paint = new TextPaint(); paint.LinkColor = Base.FormattedText.Spans[counter].ForegroundColor.ToAndroid(); paint.BgColor = Base.FormattedText.Spans[counter].ForegroundColor.ToAndroid(); paint.Color = Base.FormattedText.Spans[counter].ForegroundColor.ToAndroid(); clickableSpan.UpdateDrawState(paint); clickableSpan.Click += v => { if (Base.Command != null && Base.Command.CanExecute(null)) { Base.Command.Execute(null); } }; styledString.SetSpan(clickableSpan, startIndex, endIndex, SpanTypes.ExclusiveExclusive); styledString.SetSpan(new UnderlineSpan(), startIndex, endIndex, 0); } styledString.SetSpan(new ForegroundColorSpan(Base.FormattedText.Spans[counter].ForegroundColor.ToAndroid()), startIndex, endIndex, 0); counter += 1; } //paint.LinkColor = Base.FormattedText.Spans[2].ForegroundColor.ToAndroid(); //paint.BgColor = Base.FormattedText.Spans[2].ForegroundColor.ToAndroid(); //paint.Color = Base.FormattedText.Spans[2].ForegroundColor.ToAndroid(); //styledString.SetSpan(clickableSpan, span3StartIndex, base.Control.Text.Length, SpanTypes.ExclusiveExclusive); //styledString.SetSpan(new UnderlineSpan(), span3StartIndex, base.Control.Text.Length, 0); //styledString.SetSpan(new ForegroundColorSpan(Base.FormattedText.Spans[2].ForegroundColor.ToAndroid()), span3StartIndex, base.Control.Text.Length, 0); //styledString.SetSpan(new ForegroundColorSpan(Base.FormattedText.Spans[0].ForegroundColor.ToAndroid()), 0, span3StartIndex, 0); this.Control.TextAlignment = Android.Views.TextAlignment.Center; this.Control.TextFormatted = styledString; this.Control.MovementMethod = new LinkMovementMethod(); }
private void MakeLinkClickable(ISpannable strBuilder, URLSpan span) { var start = strBuilder.GetSpanStart(span); var end = strBuilder.GetSpanEnd(span); var flags = strBuilder.GetSpanFlags(span); var clickable = new MyClickableSpan((HtmlLabel)Element, span); strBuilder.SetSpan(clickable, start, end, flags); strBuilder.RemoveSpan(span); }
protected void MakeLinkClickable(SpannableStringBuilder strBuilder, URLSpan span) { var start = strBuilder.GetSpanStart(span); var end = strBuilder.GetSpanEnd(span); var flags = strBuilder.GetSpanFlags(span); var clickable = new MyClickableSpan((LabelHtml)Element, span); strBuilder.SetSpan(clickable, start, end, flags); strBuilder.RemoveSpan(span); }