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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:15:49+00:00 2026-06-18T07:15:49+00:00

My textview contains c++ code. As it contains special characters, i have got all

  • 0

My textview contains c++ code. As it contains special characters, i have got all other character included but when i use “\n” in my code, it enters the next line and enters remaining text to next line. How can i resolve it?
Also i have included \n in start of every line because i want those lines to start from next line.
here is my layout sample:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/string_display"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="left"
        android:text="
\n #include&lt;iostream>
\n #include&lt;conio.h>
\n #include&lt;stdio.h> 
\n void main()
\n {
\n  clrscr();
\n  char a[100];
\n  cout&lt;&lt;&quot;Enter String:&quot;;
\n  cin>>a;
\n  cout&lt;&lt;&quot;String you entered:&quot;;
\n  cout&lt;&lt;a;
\n  getch();
\n }
\n \n 
//using gets function
\n //now it will include spaces
\n
\n #include&lt;iostream.h>
\n #include&lt;conio.h>
\n #include&lt;stdio.h>

\n \n void main()
\n {
\n  clrscr();
\n  char a[100]; 
\n  cout&lt;&lt;&quot;Enter String:&quot;;
\n  gets(a);
\n  cout&lt;&lt;&quot;String you entered:&quot;;
\n  cout&lt;&lt;a;
\n  getch();
\n}

"
android:textSize="20sp" />

</ScrollView>
</LinearLayout>
  • 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-18T07:15:50+00:00Added an answer on June 18, 2026 at 7:15 am

    Simply escape the newline characters that you want displayed with \\n.

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

Sidebar

Related Questions

I have a textview in my layout file. My textview contains simple c++ code.
I have a textview in my android application. textView.setText(message); Linkify.addLinks(textView, Linkify.ALL); with this code
i have a screen contains just two components 1-textView 2-button the textView starts from
I have a custom Dialog that contains only a TextView to display some text
In my app I have a textView which contains real-time messages from my app,
I have a relativelayout which contains a progressbar and a Loading textview ..i need
I have to create 1 xml which contains ImageView ImageView ImageView TextView TextView TextView
Hallo all, I have a ListView which contains a Button in each line. The
In Android ,i have a TextView ,inside the textview ,it contains some text example(22
I have made an application in that i have an activity contains a TextView

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.