Questions tagged [spanned]

The Android interface for text that has markup objects attached to ranges of it.

87 questions
5
votes
2 answers

Spanned CSS style/color

Is there any way to use spanned colors directly from a string without using any Java/Kotlin code? For example to bold text I can use " $someString " But what is the way to change color? I searched it in Android Documentation and I found…
iknow
  • 8,358
  • 12
  • 41
  • 68
5
votes
0 answers

In StyleSpan, why Typeface to NORMAL can not be applied over the Typeface to BOLD?

Button btnBold = (Button) findViewById(R.id.btnBold); btnBold.setOnClickListener(new OnClickListener() { @Override public void onClick (View v){ startSelection = etx.getSelectionStart(); endSelection =…
5
votes
2 answers

How put into list.setAdapter?

Simple but little tricky, if I have list.setAdapter(new ArrayAdapter(this,R.layout.double_row, R.id.doubleRow, articleItemsHelper)); it works if articleItemsHelper is String, but I wanna have HTML formatting in there so when…
svenkapudija
  • 5,128
  • 14
  • 68
  • 96
5
votes
0 answers

How to parcel a Spanned?

I try to parcel a Spanned but when I add bold spans, the test I wrote is not passing anymore. Here is the test : @RunWith(Parameterized.class)
 public class DNTest {
 private String testData;
 private Spanned…
Vick Tim
  • 97
  • 7
5
votes
1 answer

getSpans for Spanned String returns spans out of order?

I use the following code to sift through a Spanned String saving all bold text as a string in an array: StyleSpan[] spans = storyText.getSpans(0, storyText.length(), StyleSpan.class); List boldedWords = new ArrayList(); for…
sanic
  • 2,065
  • 4
  • 20
  • 33
4
votes
1 answer

How to change the default image (place holder) loaded in a TextView with Spanned via Html.fromHtml(text)

I have a news section on my app that loads some piece of news from my website and some of them contains images, so I load them from the internet. But while the image is not loaded, there is a green square that only disappears when the image…
GLAPPs Mobile
  • 99
  • 1
  • 1
  • 12
4
votes
1 answer

How to change one span type to another in Android?

I would like to take all the spans of one type in a CharSequence and convert them to a different type. For example, convert all the bold spans to underline spans: How would I do that? (This was a problem I was facing today, and since I have solved…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
4
votes
0 answers

comparing two spanned strings in edittext in android

I am having a strange problem in my app. I have an edittext where I am getting some user input text. I am also enabling user to add formatting (Bold/italic etc) as well to the entered string. I then store that string into a json string. Further on…
user1938357
  • 1,466
  • 3
  • 20
  • 33
4
votes
0 answers

Android. Text spans disappear on backspace press and act weird overall

I need to implement a wysiwyg EditText and I faced a problem at the very beginning. So I added the following code to onTextChanged: int textLen = textWord.getText().length(); if (s.length() > textWordBefore.length()) { if (boldToggle == true) { …
Alexander
  • 631
  • 1
  • 8
  • 19
4
votes
2 answers

Spanned as from Html.fromHtml, but with custom ClickableSpan for custom scheme

I have a TextView that displays some HTML code (images included, ImageGetter). The html is not mine, but I can ask them to include custom scheme links, maybe even tags. Purpose: to display some dynamically generated content without the need to play…
kaay
  • 1,083
  • 1
  • 12
  • 31
3
votes
1 answer

TextView renders ugly bullets for
  • tags
  • We have the next input String: String test = "
  • Some text
  • \n" + "
  • Some text
  • \n" + "
  • Some text
  • "; Then we create spanned via and set it into the TextView: Html.fromHtml(test); As a result, I will get…
    Maxim Petlyuk
    • 1,014
    • 14
    • 20
    3
    votes
    3 answers

    Android - Breaking down a Spanned object

    spanned = Html.fromHtml("aaabbbcccddd"); Will create a Spanned object with with 3 spans aaa, ccc, ddd. bbb is being ignored since it's not inside an html tag, spans = spanned.getSpans(0, spanned.length(),…
    Aviran
    • 5,160
    • 7
    • 44
    • 76
    2
    votes
    0 answers

    Textview starting next to view on a line and back to begining on the next

    I'm sorry I didn't find a clearer title :/ I'm not english native, if you've a better idea, please tell me. I'm looking for coding a view like that : my problem is to start the body of my cell next to the name of the name of the author (which…
    Renaud Favier
    • 1,645
    • 1
    • 17
    • 33
    2
    votes
    2 answers

    Spanned text in Number picker

    I have a problem with to show meter m2 in android. I can use SpannedBuilderString for setText in TextView and it work. The problem is I want to show m2 in Number Picker like 50 m2 100 m2 but Number Picker only show String and I can't. Please help…
    ToraCode
    • 421
    • 8
    • 19
    2
    votes
    0 answers

    Android N - Spanned.subSequence from Html get exception StringIndexOutOfBoundsException on some case

    I'm facing this exception on Android N : java.lang.StringIndexOutOfBoundsException line : res.add(new SpannableStringBuilder(in.subSequence(lastImageSpanPosition, spanStart))); I don't know why fromHtml medthod in android N returning different…
    Dao Quoc Khanh
    • 613
    • 1
    • 7
    • 13