Layout änderung bringt App zum Crash

  • 3 Antworten
  • Letztes Antwortdatum
Murdock1

Murdock1

Ambitioniertes Mitglied
7
Hi,

ich hab diese Layout, wenn ich im 2. LinearLayout, die SeekBar vor den beiden ProgressBars mache knallts direkt beim start, lass ich den Code so läuft es wie es muss. Im LogCat steht ich würde ProgressBar als SeekBar casten, was aber mumpitz ist. Was kann das denn sein?
Code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    android:gravity="center|bottom" 
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp" 
        android:layout_marginBottom="@dimen/activity_vertical_margin">

        <TextView
            android:id="@+id/textViewTags"
            android:textColor="@color/darkersilver"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="@string/empty"
            android:textAppearance="?android:attr/textAppearanceLarge" >            
        </TextView>        
    </LinearLayout>
        
    <LinearLayout
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
        android:orientation="vertical" >
                
        <ProgressBar
            android:id="@+id/progressBarPeakL"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="4dp"
            android:max="32767"
            android:progress="0"
            android:progressDrawable="@drawable/peakbar" >            
        </ProgressBar>
        
        <ProgressBar
            android:id="@+id/progressBarPeakR"
            style="?android:attr/progressBarStyleHorizontal"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:max="32767"
            android:progress="0"
            android:progressDrawable="@drawable/peakbar">            
        </ProgressBar>    
        
        <SeekBar
            android:id="@+id/seekBarVolume"
            android:max="100"
            android:progress="50"
            android:layout_marginBottom="@dimen/activity_vertical_margin"
            android:thumb="@drawable/thumb"
            android:progressDrawable="@drawable/progress"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">               
           </SeekBar> 
        
       </LinearLayout>
       
    
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical"
        android:background="?android:attr/selectableItemBackground"
        android:gravity="center|bottom" >
        
        <Button
            android:id="@+id/buttonPlay"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/buttons"
            android:text="@string/play"
            android:textColor="@color/darkersilver" >            
        </Button>

        <Button
            android:id="@+id/buttonPause"
            android:layout_marginLeft="8dp"
            android:layout_marginRight="8dp"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/buttons"
            android:text="@string/pause"
            android:textColor="@color/darkersilver" >            
        </Button>
        
        <Button
            android:id="@+id/buttonStop"
            android:layout_weight="1"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:background="@drawable/buttons"
            android:text="@string/stop"
            android:textColor="@color/darkersilver" >            
        </Button>        
    </LinearLayout>

</LinearLayout>
Code:
pgbPeakR = (ProgressBar)layout.findViewById(R.id.progressBarPeakR);
pgbPeakL = (ProgressBar)layout.findViewById(R.id.progressBarPeakL);
skbVolume = (SeekBar)layout.findViewById(R.id.seekBarVolume);
skbVolume.setOnSeekBarChangeListener(this);
LogCat:
Code:
03-20 20:09:33.032: E/AndroidRuntime(22923): FATAL EXCEPTION: main
03-20 20:09:33.032: E/AndroidRuntime(22923): java.lang.ClassCastException: android.widget.ProgressBar cannot be cast to android.widget.SeekBar
03-20 20:09:33.032: E/AndroidRuntime(22923):     at de.murdock.droidradio.MainFragment.onCreateView(MainFragment.java:107)
03-20 20:09:33.032: E/AndroidRuntime(22923):     at android.support.v4.app.Fragment.performCreateView(Fragment.java:1504)
03-20 20:09:33.032: E/AndroidRuntime(22923):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:942)
 
Zuletzt bearbeitet:
Mal Clean & Rebuild ausprobiert?
 
  • Danke
Reaktionen: Murdock1
Japp, nachdem du gefragt hast:thumbsup:. Das haut mich jetzt allerdings vom Hocker das es nun funktioniert. Das hatte ich noch nie bei einer Layout änderung gehabt.
 
Freut mich ;)
 

Ähnliche Themen

K
Antworten
3
Aufrufe
502
mezzothunder
mezzothunder
B
Antworten
9
Aufrufe
393
jogimuc
J
J
Antworten
5
Aufrufe
353
swa00
swa00
Zurück
Oben Unten