Ok I have declared my main.xml as follows
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal" >
<RelativeLayout
android:id="@+id/AdMob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true" >
</RelativeLayout>
<ScrollView
android:id="@+id/scrollview1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/AdMob" >
<TableLayout
android:id="@+id/tablelayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TableRow
android:id="@+id/tableRow0"
android:layout_height="wrap_content"
android:background="@drawable/banner" />
<TableRow
android:id="@+id/tableRow1"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/start_message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textSize="15sp" />
</TableRow>
<TableRow
android:id="@+id/tableRow2"
android:layout_height="wrap_content" >
<Button
android:id="@+id/start"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:text="Start Now" >
</Button>
</TableRow>
</TableLayout>
</ScrollView>
</RelativeLayout>
and my main activity is
package com.michaelpeerman.demotivational_posters;
import com.michaelpeerman.demotivational_posters.R;
import android.app.Activity;
import android.os.Bundle;
import android.text.Html;
import android.widget.TextView;
public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView start_message = (TextView) findViewById(R.id.start_message);
start_message.setText(Html.fromHtml("Thank you for downloading \"Demotivational Posters\" \n Click start below to start. \n To advance to the next picture click the \"Next\" button. \n If you see an image you would like to download click the \"Download\" button. \n If you enjoy this app please leave a rating."));
}
}
When i go to compile my program it force closes automatically. The logcat output is
03-13 01:59:50.240: E/AndroidRuntime(14336): FATAL EXCEPTION: main
03-13 01:59:50.240: E/AndroidRuntime(14336): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.michaelpeerman.demotivational_posters/com.michaelpeerman.demotivational_posters.MainActivity}: java.lang.ClassCastException: android.widget.TableRow cannot be cast to android.widget.TextView
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.os.Handler.dispatchMessage(Handler.java:99)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.os.Looper.loop(Looper.java:137)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-13 01:59:50.240: E/AndroidRuntime(14336): at java.lang.reflect.Method.invokeNative(Native Method)
03-13 01:59:50.240: E/AndroidRuntime(14336): at java.lang.reflect.Method.invoke(Method.java:511)
03-13 01:59:50.240: E/AndroidRuntime(14336): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-13 01:59:50.240: E/AndroidRuntime(14336): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-13 01:59:50.240: E/AndroidRuntime(14336): at dalvik.system.NativeStart.main(Native Method)
03-13 01:59:50.240: E/AndroidRuntime(14336): Caused by: java.lang.ClassCastException: android.widget.TableRow cannot be cast to android.widget.TextView
03-13 01:59:50.240: E/AndroidRuntime(14336): at com.michaelpeerman.demotivational_posters.MainActivity.onCreate(MainActivity.java:16)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.Activity.performCreate(Activity.java:4465)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-13 01:59:50.240: E/AndroidRuntime(14336): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-13 01:59:50.240: E/AndroidRuntime(14336): ... 11 more
I can not figure out what it means that i casted the tablerow to textview
You need to clean and rebuild your project once again. If that is not working then close your project and open once again refresh the project and run. I tried with your given code. It is working in my case.