title: Android TextView in ScrollView not working- Force Close
body: <p>Im trying to create a textview that is able to scroll a large amount of text. I nested it inside of a scrollview and I get force closes on my phone and tablet when attempting to test it. When I run without the scrollview, it works, but does not scroll, obviously. Here is what I have in my XML file for the layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent" android:layout_height="fill_parent"
  android:scrollbars="horizontal" android:isScrollContainer="true"&gt;    
   &lt;LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical" &gt;
  
     &lt;TextView
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:id="@+id/tutView"&gt;
  
     &lt;/TextView&gt;
   &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  </code></pre>
  
  <p>EDIT: LogCat info:</p>
  
  <pre><code>02-10 14:51:44.402: W/dalvikvm(5948): threadid=1: thread exiting with uncaught exception (group=0x40a3c1f8)
  02-10 14:51:44.414: E/AndroidRuntime(5948): FATAL EXCEPTION: main
  02-10 14:51:44.414: E/AndroidRuntime(5948): java.lang.RuntimeException: Unable to start activity ComponentInfo{rg.ah/rg.ah.TutViewerActivity}: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread.access$600(ActivityThread.java:123)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.os.Handler.dispatchMessage(Handler.java:99)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.os.Looper.loop(Looper.java:137)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread.main(ActivityThread.java:4424)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at java.lang.reflect.Method.invoke(Method.java:511)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at dalvik.system.NativeStart.main(Native Method)
  02-10 14:51:44.414: E/AndroidRuntime(5948): Caused by: java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.view.ViewGroup.addViewInner(ViewGroup.java:3337)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.view.ViewGroup.addView(ViewGroup.java:3208)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.view.ViewGroup.addView(ViewGroup.java:3188)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:260)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.Activity.setContentView(Activity.java:1855)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at rg.ah.TutViewerActivity.onCreate(TutViewerActivity.java:25)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.Activity.performCreate(Activity.java:4465)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
  02-10 14:51:44.414: E/AndroidRuntime(5948):     ... 11 more
  02-10 14:51:44.496: D/dalvikvm(5948): GC_CONCURRENT freed 192K, 4% free 9285K/9607K, paused 2ms+9ms
  </code></pre>
  
  <p>EDIT 2: Added my onCreate for the error in question. This takes the item that was touched in a list on the main view and displays this with more information in a textview.</p>
  
  <pre><code>public class TutViewerActivity  extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.textview);
  
      Intent launchingIntent = getIntent();
      String content = launchingIntent.getData().toString();
  
      TextView viewer = (TextView) findViewById(R.id.tutView);
      viewer.setMovementMethod(new ScrollingMovementMethod());
      viewer.setText(Html.fromHtml(content));
  
      setContentView(viewer);
  }
  }
  </code></pre>