1

In my app I need to pull text from this website. http://www.cellphonesolutions.net/help-en-lite

Notice how its a very large file. When I try to pull the text it doesn't get the first half of the text. Is there a limit to the amount of characters a textview can hold? if so how do I go around this problem. Here is the code I use to gather the text.

//in the oncreate method

    TextView faq = (TextView) findViewById(R.id.tvfaq);
    faq.setText((Html.fromHtml(
            cleanhtml(getText("http://www.cellphonesolutions.net/help-en-lite)
            )));

This clears up the comments that Html.fromHtml doesn't filter out

public String cleanhtml(String original) {
    String finalText = original.replaceAll("<![^>]*>", "");

    return finalText;
}

This is how I get the text from the website

public String getText(String uri) {
    HttpClient client1 = new DefaultHttpClient();
    HttpGet request = new HttpGet(uri);

    ResponseHandler<String> responseHandler = new BasicResponseHandler();
    try {
        String response_str = client1.execute(request, responseHandler);
        return response_str;

    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return "";

    }
}

Here is my xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:background="@drawable/splash_fade"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content">
    <TextView android:layout_gravity="center" android:text="TextView" android:gravity="center"
        android:id="@+id/tvfaq" android:layout_width="wrap_content" android:textColor="#000000"
        android:layout_height="wrap_content"></TextView>
</ScrollView>
</LinearLayout>
Sean Pan
  • 493
  • 2
  • 6
  • 21

3 Answers3

4

Try to remove the ScrollView

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:background="@drawable/splash_fade"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_gravity="center" android:text="TextView" android:gravity="center"
        android:id="@+id/tvfaq" android:layout_width="wrap_content" android:textColor="#000000"
        android:layout_height="wrap_content"></TextView>
</LinearLayout>

TextView has an implemeted scroller that will do what you expect with a scrollview.

UPDATE

you need to apply that to your textView faq.setMovementMethod(new ScrollingMovementMethod());

If that doesn't work try to debug your application and see if response_str has all the characters from the website

weakwire
  • 9,284
  • 8
  • 53
  • 78
1

Is your TextView wrapped around ScrollView. Inherently TextView does not have scrolling capability , so overflown text will get cut of from display.

to prevent this use wrap a ScrollView around your textview , something like this in xml

<ScrollView android:id="@+id/ScrollView01" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:fillViewport="true">
<TextView 
    android:layout_height="wrap_content" 
    android:id="@+id/TextView01"
    android:layout_width="fill_parent" 
    />
</ScrollView>
Anuj Tenani
  • 2,084
  • 2
  • 23
  • 31
  • yes it is, I will edit my question and show my xml, the problem isn't that it can't scroll but that not all the text is appearing which is quite strange – Sean Pan Sep 02 '11 at 21:33
0

I'm also experiencing this bug. I've found that arbitrary paddingBottom values fix it -- but I hate this solution.

I'm convinced it's a bug in android.

Skone
  • 745
  • 4
  • 13