android.widget.TextView cannot be cast to android.view.ViewGroup0 -
cannot find source of error. saw other questions concerning same problem, caused missing closing-tag. cannot find 1 missing in code...
my main activity.xml file:
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context=".mainactivity" android:orientation="horizontal"> <textview android:text="@string/main_textview" android:layout_width="0px" android:layout_weight="2" android:background="#fff8dc" android:padding="@dimen/component_padding" android:layout_height="match_parent" > </textview> <textview android:id="@+id/simplefragment" android:layout_width="0px" android:layout_weight="2" android:orientation="vertical" android:padding="@dimen/component_padding" android:layout_height="match_parent" > </textview> </linearlayout>
and 1 fragment:
<textview android:text="@string/hello_world" android:layout_width="match_parent" android:layout_height="match_parent" > </textview> </linearlayout>
logcat says:
java.lang.runtimeexception: unable start activity componentinfo{com.example.melle.androidfragments/com.example.melle.androidfragments.mainactivity}: java.lang.classcastexception: android.widget.textview cannot cast android.view.viewgroup caused by: java.lang.classcastexception: android.widget.textview cannot cast android.view.viewgroup
viewgroup
means view can have other views inside it. you're opening , closing textviews separately, making them group when can't.
based on code posted, solution remove </textview>
, close directly @ end of attributes />
, this, example:
<textview android:id="@+id/simplefragment" android:layout_width="0px" android:layout_weight="2" android:orientation="vertical" android:padding="@dimen/component_padding" android:layout_height="match_parent" />
do in of textviews. also,check if there <textview>
tag other view inside it, if should remove , put somewhere else.
Comments
Post a Comment