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 6811443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:19:40+00:00 2026-05-26T20:19:40+00:00

I have a TextView to be used as a bluetooth connection console. When I

  • 0

I have a TextView to be used as a bluetooth connection console. When I send a command, I want it to be written in a color (for example cyan), and the answers received in a different color (for example red).

Is it possible to do that, and if so, how?

I read it may be possible to do using HTML, but i’m not quite sure it is the best approach, or even how to do it.

  • 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-05-26T20:19:41+00:00Added an answer on May 26, 2026 at 8:19 pm

    Do you really need it to be a TextView or can you use a ListView instead and add a new row in the list for each command/answer?

    If you really want to use a TextView you can do something like this (This is a working example you can just copy and paste to your app to try out):

    package com.c0deattack;
    
    import android.app.Activity;
    import android.graphics.Color;
    import android.os.Bundle;
    import android.text.Spannable;
    import android.text.style.ForegroundColorSpan;
    import android.widget.LinearLayout;
    import android.widget.TextView;
    
    public class MultipleColoursInOneTextViewActivity extends Activity {
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            TextView tv = new TextView(this);
    
            String command = "This is a command";
            String response = "\nThis is a response";
    
            tv.append(command + response);
            Spannable spannableText = (Spannable) tv.getText();
            spannableText.setSpan(new ForegroundColorSpan(Color.GREEN), 0, command.length(), 0);
            spannableText.setSpan(new ForegroundColorSpan(Color.RED), command.length(), command.length() + response.length(), 0);
    
            LinearLayout layout = new LinearLayout(this);
            layout.addView(tv);
            setContentView(layout);
        }
    }
    

    So that shows that it can be done, but you’ll obviously notice you’ll have to set the line breaks yourself and workout where each command/answer starts and ends so you can apply the correct colour to it. It’s not that hard but to me, feels clunky.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gtk.Textview . I want to find and select some of the
I want to have a class Utils, that will have several methods used all
((TextView)((FrameLayout)((LinearLayout)((ViewGroup)getWindow().getDecorView()).getChildAt(0)).getChildAt(0)).getChildAt(0)).setGravity(Gravity.CENTER); I have used this above code for aligning my title of activity in
I have used a customized list view in which i have added 4 TextView
How to set underline text on textview ? I have used following code but
I have a TextView which height is dynamic. I want to set that the
I have an empty TextView set for my ListView . When there is no
I have a clickable TextView with a drawable as its background. I'm looking for
I have the following TextView in my XML layout file:- <TextView android:layout_width=fill_parent android:layout_height=wrap_content android:text=@string/autolink_test
I have an ArrayAdapter (myAdapter) attached to an AutoCompleteTextView (textView) component. Once the user

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.