Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] android – Multiple spannableString.setSpan in a loop

Posted on November 11, 2022 By

Solution 1 :

A single span can only have one location within a SpannableString or SpannableStringBuilder. To color multiple ranges, you need to create a different span for each range.

Problem :

I’m creating a calculator app using Kotlin. I want to highlight the operation characters (+, -, *, /) by making their color blue.
The array operationsInStrings is filled with indexes of characters from string that I wish to change the color to blue. Only the last member of the array turns to blue color
Emulator screenshot. I tried using both spannableString and SpannableStringBuilder, but I’m probably doing something wrong as I’m new to the language. The array is filled correctly, as I tested it.
Function code

READ  [FIXED] Publish React Native (Android) app to multiple clients
Powered by Inline Related Posts
Android Tags:android, kotlin, spannablestring, spannablestringbuilder

Post navigation

Previous Post: [FIXED] android – W/Firestore: (24.1.2) [CustomClassMapper]: No setter/field for about found on class
Next Post: [FIXED] android – FusedLocationProviderClient and LocationCallback() object queries

Related Posts

[FIXED] java – My app force close when call putString on SharedPreference.Editor Android
[FIXED] android – Break the flatMapIterable loop RXJava Android
[FIXED] android – How to change TextView based onNavigationItemSelected? Android
[FIXED] android – When library dependency is added using ‘api’ does not provide access to their library which is declared using ‘implementation’ in Gradle? Android
[FIXED] How do I force my Android phone network to work on 2g/3g only pragmatically? Android
[FIXED] Launching react-native-navigation screen from Android Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme