I have designed the layout for one of my activities but i am getting strange error . This is simple activity actually it is main menu activity which contains imagebuttons in it.
"07-12 16:40:22.599: E/AndroidRuntime(1857): Caused by: java.lang.ClassCastException: android.widget.LinearLayout
"
Here is my layout xml Code
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@drawable/rpg"
android:orientation="vertical" >
<TableLayout
android:id="@+id/tableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageButton
android:id="@+id/profile_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/a1" />
<TextView android:text=" " />
<ImageButton
android:id="@+id/share_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/a2" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageButton
android:id="@+id/settings_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/a3" />
<TextView android:text=" " />
<ImageButton
android:id="@+id/contacts_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/a4" />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<TextView android:text=" " />
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<ImageButton
android:id="@+id/exit_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/a5" />
<TextView android:text=" " />
<ImageButton
android:id="@+id/amazon_btn"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="@drawable/amazon" />
</TableRow>
</TableLayout>
<LinearLayout
android:id="@+id/ban2_mainmenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@drawable/ban_2" >
</LinearLayout>
<LinearLayout
android:id="@+id/ban1_mainmenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/ban2_mainmenu"
android:background="@drawable/ban_1" >
</LinearLayout>
</RelativeLayout>
</ScrollView>
In java at first line of this code below i am getting error
ImageButton amazon = (ImageButton) findViewById(R.id.amazon_btn);
amazon.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// TODO Auto-generated method stub
Intent browse = new Intent(Intent.ACTION_VIEW, Uri
.parse("http://www.amazon.com/gp/product/B0084FCDKS"));
startActivity(browse);
}
});
Error is
07-12 16:40:22.599: E/AndroidRuntime(1857): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.colony.rpgbluetoothchatlite/com.colony.rpgbluetoothchatlite.Menu_Main}: java.lang.ClassCastException: android.widget.LinearLayout
07-12 16:40:22.599: E/AndroidRuntime(1857): Caused by: java.lang.ClassCastException: android.widget.LinearLayout