android.widget.TextView无法强制转换为android.view.ViewGroup

dom*_*yra 12 xml android

所以android.view.ViewGroup当我尝试在图形视图中查看我的xml时,我没有看到它在哪里投入到我收到此错误消息.我还没有对这个实际的java做任何事情.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffffffff"
android:orientation="vertical" >

<TableLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center"
    android:stretchColumns="1" >

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="1.0dp"
        android:background="@drawable/list_divider_holo_light" />

    <TableRow
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >
Run Code Online (Sandbox Code Playgroud)

在这里,我厌倦了用这些元素制作一种风格,它不会接受它.

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="25dp"
            android:text="@string/add_alarm"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:textColor="#ff505050"
            android:textSize="18.0sp" />

        <Button
            android:id="@+id/bSetTimer"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="100.0dp"
            android:text="Button" />
    </TableRow>

    <Button
        android:id="@+id/bSetAlarm"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Button" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Small Text" >

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="2.0dp"
            android:background="@drawable/list_divider_holo_light" />

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:paddingTop="10dp" >

            <TextView
                android:layout_height="20.0dp"
                android:layout_gravity="center_horizontal"
                android:layout_marginLeft="40.0dp"
                android:paddingLeft="25.0dip"
                android:text="@string/alarm_volume_title" />
        </TableRow>

        <SeekBar
            android:id="@+id/default_volume_seekbar"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="15.0dp"
            android:paddingTop="2.0dip" />
    </TextView>
</TableLayout>
Run Code Online (Sandbox Code Playgroud)

che*_*g81 21

文本视图textView2不封闭的(它只是关闭表前layout),并且运行时尝试将其转换为viewgroup以添加2个表行seekbar.


kab*_*uko 5

你正试图在你的TextView(@+id/textView2)中放入其他元素.这是无效的,因为正如错误所说,它不是一个ViewGroup.