2012-03-25 138 views
0

當按下停止和播放按鈕時,我正在將新圖像加載到圖像視圖中。他們來回切換。但是,當我在我的代碼中設置圖像源顯得非常錯誤。設置ImageView源無法正常工作

之前

enter image description here

然後我打電話

bottomBar.setImageResource(R.drawable.bottombuttonsstop); 

最終結果

enter image description here

佈局XML

<LinearLayout 
    android:id="@+id/bottomBarBox" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" > 
    <ImageView 
     android:id="@+id/bottomBar" 
     android:layout_width="match_parent" 
     android:background="@drawable/bottombuttons" 
     android:layout_height="wrap_content" /> 
</LinearLayout> 

顯然這是不是正確加載由於某種原因,任何想法?

回答

1

嘗試撥打setBackgroundResource而不是setImageResource或在佈局文件中設置android:src