2011-12-15 68 views
11

所以我沒有看到它將它轉換爲android.view.ViewGroup當我嘗試在圖形視圖中查看我的xml時,出現此錯誤消息。我還沒有做過任何與這個屬於的Java實際相關的東西。android.widget.TextView無法轉換爲android.view.ViewGroup

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

回答

21

文本視圖textView2沒有關閉(它只是關閉表layout之前),以及運行時嘗試將其轉換爲viewgroup以添加2級表中的行和seekbar

+0

哦....哇我正在尋找它在我的textView1 ...哈哈謝謝你! – domshyra 2011-12-15 20:49:12

5

您正試圖將其他元素放入您的TextView@+id/textView2)中。這是無效的,因爲如錯誤所述,它不是ViewGroup

+0

非常感謝你:) – domshyra 2011-12-15 20:49:28

相關問題