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

12

所以我不知道它在哪里将其转换为 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" >

我试图使用这些元素创建一个样式,但它无法接受。

        <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>

2个回答

21

textView2这个文本视图没有被关闭(它位于关闭表格layout之前),运行时尝试将其转换为viewgroup以添加2个表格行和一个seekbar


5
您正在尝试将其他元素放置在您的TextView (@+id/textView2)中。这是无效的,因为如错误所示,它不是一个ViewGroup

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接