Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8255299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:28:31+00:00 2026-06-08T01:28:31+00:00

I have an EditText view which I am using to display information to the

  • 0

I have an EditText view which I am using to display information to the user. I am able to append a String and it works correctly with the following method:

      public void PrintToUser(String text){
         MAIN_DISPLAY.append("\n"+text);
      }

The application is an RPG game which has battles, when the user is fighting I would like to display the String in RED. So I have attempted to use a SpannableString. (changed the method)

       public void PrintToUser(String text, int Colour){
    
       if(Colour == 0){
       //Normal(Black) Text is appended
       MAIN_DISPLAY.append("\n"+text);
        
        
       }else{
       //Colour text needs to be set.
    

       //Take the CurrentText
       String CurrentText = MAIN_DISPLAY.getText().toString();
       CurrentText = CurrentText+"\n";
        
       SpannableString SpannableText = new SpannableString(CurrentText + text);  
    
       switch(Colour){
       case 1:
              SpannableText.setSpan(new ForegroundColorSpan(Color.RED), CurrentText.length(), SpannableText.length(), 0); 
       break;
       }
    

     //You cannot append the Spannable text (if you do you lose the colour)
    MAIN_DISPLAY.setText(SpannableText, BufferType.SPANNABLE);
    }

This new method works and the new line is displayed is red.

Problems

  1. Only the last line formatted is red. If a new line is set to be red the previous formatting is lost due to the way I retrieve the text

    String CurrentText = MAIN_DISPLAY.getText().toString();

  2. When I was ONLY appending Strings to the EditText it was displaying the bottom of the EditText box (the last input) now when using SetText the users see’s the Top.

Finally My Question:

Is there a way to Append the formatted text?

OR… Can I retrieve the formatted text from the EditText and then when I use .setText I can keep the current format?

AND if so… Is there a way to focus the Display at the Bottom opposed to the Top?

Thank you! Please comment if additional information is needed I’ve been stuck on this for a while now.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:28:32+00:00Added an answer on June 8, 2026 at 1:28 am

    The following modifications to PrintToUser() should work..

    public void PrintToUser(String text, int Colour){
        ...
        ...
        Editable CurrentText = MAIN_DISPLAY.getText();
        int oldLength = CurrentText.length();
        CurrentText.append("\n" + text); 
    
        switch(Colour){
           case 1:
             CurrentText.setSpan(new ForegroundColorSpan(Color.RED), 
                                 oldLength, CurrentText.length(), 0); 
           break;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an EditText which takes a String from the user and a searchButton.
I have an EditText view which will allow the user to edit an address
I have a layout which has one large EditText view at the top +
I have a view in which there is a text box where user enters
I have a activity, which view have a several EditText components. When activity starts,
I have an EditText View which is edited by setText() from my code and
I have an EditText that I'm using as the footer View for my ListView
I have a custom dialog with one editText view and two buttons ok and
I have a list view, editText and button. editText and button are my footer
I have an EditText, which generally shows parallel to the screen X-axis. I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.