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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:32:42+00:00 2026-05-31T09:32:42+00:00

I have a TextView that I am trying to make display a 2d character-based

  • 0

I have a TextView that I am trying to make display a 2d character-based grid. In my Java code I have created a 2d array, I take that array filled with strings and append each entry one next to another, and when the end of the array row is reached, i also append a newline character (.n). In this way I then take the big long singular string full of all the entries in the array (in order with the \n) and do setText(string). That way, the TextView is supposed to display a 2d grid on the display. It sort-of does this: the top row and the bottom row are both fine, but every row in between there are missing spaces between the end character in the row, and somewhere (approximately 13 characters) from the left side.

Here is the code snippets from making the array, filling it with characters, and making that array into a long string:

    for(int row = 0; row < 22; row++){
        for(int column = 0; column < 22; column++){
            if(row == 0 || row == 21){
                playField[row][column] = "#";
            }else if(row > 0 && row < 21 ){
                if(column == 0 || column == 21){
                    playField[row][column] = "#";
                }else{
                    playField[row][column] = " ";
                }                   
            }
        }

Now, the turning the array into a string:

    temp = new String();
    for(int i = 0; i < 22; i++){
        for(int j = 0; j < 22; j++){
            temp+=playField[i][j];
        }
        temp+="\n";
    }return temp;

This string is what I use text.setText(temp) on, and it works, but it goes like this: # in column 1, about 10 blank spaces (as intended) then another # in column 13 or so, and then next row. On the top row, there are all 22 # signs, and on the bottom row there are all 22 # signs.

I have my textView set as such in the xml:

    <TextView
    android:id="@+id/grid"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"/>
  • 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-31T09:32:43+00:00Added an answer on May 31, 2026 at 9:32 am

    I think the problem is that you didn’t declared your TextView to use the monospace typeface, so all the spaces are there, but they are not as wide as the # symbol.

    You can specify the typeface of the TextView like this:

    android:typeface="monospace"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a custom Dialog that contains only a TextView to display some text
I'm trying to make a textview that scales the contents so that it all
I have been trying to figure out how to make a custom chronometer that
How to make an EditText look like a TextView that is done in Java
I have a Cocoa app I'm writing that has an ImageView with a TextView
I have created an App Widget for Android 1.5. It uses a TextView to
Do I have to do anything special to display UTF-8 characters in a TextView?
I am trying to make programatically a PaintDrawable background for a TextView so it
I am trying to make an Android interface, but I have a little overlapping
I have the following XML. I'm trying to make a static button underneath my

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.