2011-12-15 14 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を閉じる前にある)を閉じていない、とランタイムは2テーブルの行を追加するためにviewgroupにキャストしようとしていますおよびseekbar

+0

oh ....うわー私のテキストでそれを探していましたView1 ...ありがとう! – domshyra

5

TextView@+id/textView2)内に他の要素を挿入しようとしています。エラーが示すように、それはViewGroupではないため、有効ではありません。

+0

ああ、ありがとうございます:) – domshyra

関連する問題