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

  • Home
  • SEARCH
  • 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 7682571
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:35:55+00:00 2026-05-31T18:35:55+00:00

I need to add text to a ScrollableLayout after it’s remotely retrieved from an

  • 0

I need to add text to a ScrollableLayout after it’s remotely retrieved from an AsyncTask. Since I don’t know the number of strings involved, I need to programmatically create as many TextViews as needed.

Layout code

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/view_phone_mainView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <LinearLayout
        android:id="@+id/view_phone_linearLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="top" >

        <TextView
            android:id="@+id/view_phone_lblTitle"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal|center_vertical"
            android:text="@string/view_phone_title"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/view_phone_lblWarning"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/view_phone_warning"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:visibility="invisible" />

    </LinearLayout>

</ScrollView>

Activity

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        pDialog = new ProgressDialog(this);
        pDialog.setIndeterminate(true);
        pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        pDialog.setMessage(getString(R.string.view_phone_wait));

        pDialog.show();

        task = new MessageLoaderTask(); //Returns String[] on callback
        task.execute((Void) null);
    }

    public void onRulesLoaded(String[] messages) { //Directly called by OnPostExecute
        LinearLayout container = (LinearLayout) findViewById(R.id.view_phone_linearLayout);
        if (messages != null) {

            for (String m : messages) {
                TextView tv = new TextView(this);
                tv.setText(m);
                tv.setTextAppearance(this, android.R.attr.textAppearanceSmall);
                tv.setVisibility(View.VISIBLE);
                tv.setBackgroundColor(Color.TRANSPARENT);
                tv.setTextColor(Color.BLACK);

                container.addView(tv, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
            }
        }

        pDialog.dismiss();
    }

I am sure, by debug, that strings are correctly valued. The result is that the title label gets displayed, the warning is hidden but below there is only white……

I tried to scroll and noticed that the scrolling area is veeeeeeeeeery long, compatible with the long Lorem ipsum stub text I used for testing. If I truncate via debug one of the strings to empty (there are only 2) the scrollable area is shorter in height. I use the light theme, so I expect black text on white background.

tv.setTextAppearance(this, android.R.attr.textAppearanceSmall);
tv.setVisibility(View.VISIBLE);
tv.setBackgroundColor(Color.TRANSPARENT);
tv.setTextColor(Color.BLACK);

were added at a second time when everything was failing. No difference whether they are in place or not. What can I do to fix?

Thanks

  • 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-31T18:35:57+00:00Added an answer on May 31, 2026 at 6:35 pm

    Not sure why your ScrollView would be increasing in length if this were the sole problem, but it seems like you need to set your LinearLayout’s orientation to vertical.

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

Sidebar

Related Questions

I have a Java array of strings. I need to add some text before
i need to add a special text to all rows in my mysql table
I need to add markup to some text using JavaScript regular expressions. In Python
I need to add text before the last line in a text file in
I need to add two text view to the list view as shown in
Question explains it all really, I need to add some text to a PDF
I have Rails app with a Postgres backend. I need to add full text
In my view I need to add (dynamically) text inputs and I need to
i need to add textfield text to NSMutable string when end of the textfield
I need to add some numbers / text, programmatically so it shows on top

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.