2011-12-15 4 views
11

그래서 그것을 캐스팅하는 곳으로 표시되지 않습니다 android.view.ViewGroup 그래픽보기에서 내 XML을 보려고하면이 오류 메시지가 나타납니다. 나는 이것도 관련이 실제 자바 아무것도하지 못했습니다.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에 캐스팅하려고하는 두 테이블 행을 추가하지 않습니다 및 seekbar.

+0

오 .... 와우 나는 내 텍스트에서 그것을 찾고있었습니다 View1 ... 하하 감사합니다! – domshyra

5

TextView (@+id/textView2) 안에 다른 요소를 넣으려고합니다. 오류로 인해 ViewGroup이 아니기 때문에 유효하지 않습니다.

+0

아, 정말 고마워요 :) – domshyra

관련 문제