当前位置: 代码迷 >> Android >> 急求帮看一下android XML的有关问题T.T
  详细解决方案

急求帮看一下android XML的有关问题T.T

热度:11   发布时间:2016-04-28 04:13:51.0
急!!求帮看一下android XML的问题T.T
本帖最后由 MrIELTS 于 2013-01-30 18:08:44 编辑
本来我的程序运行得好好的,结果我在XML布局文件中添加了一个imageview后,报了很不可思议的错误T.T....
下面是XML:
<ImageButton 
            android:id="@+id/play_back"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginRight="15dp"
             android:cacheColorHint="#00000000"
            android:background="@drawable/back"
            />
        <ImageView 
        android:id="@+id/imageview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scaleType="fitXY" 
        android:background="@drawable/next">
        </ImageView>
        <TextView 
            android:id="@+id/songTitle"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            android:text="播放歌曲"
            android:scrollHorizontally="true"
android:marqueeRepeatLimit="marquee_forever"
android:ellipsize="marquee"
android:focusable="true" 
 android:focusableInTouchMode="true" 
android:singleLine="true"
            android:textSize="30dp"
            android:textColor="#FFFFFF"/>

其中imageview就是我新添加的。。。添加之后运行程序报这个错误:
java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.ImageButton
at com.example.musicplayer.KekeMusic.initPlayView(KekeMusic.java:413)
下面是我第413行代码:
//离开播放页
     ImageButton leavePlay = (ImageButton) findViewById(R.id.play_back);

怎么都想不明白我这段代码怎么就是把imageview转化成imagebutton了
求解答啊。。。。
------解决方案--------------------
android.widget.ImageView cannot be cast to android.widget.ImageButton
这句话的意思也有:ImageView 不能被扔到 ImageButton 中 

下面可能有问题;
android:layout_width="match_parent"
android:layout_height="match_parent"

三个的位置没法处理
  相关解决方案