2014-10-09 29 views
0

(內部列表getView) 我動態地創建StateListDrawablesetBackgroundDrawable()使用它:如何使用setBackgroundDrawable和setBackground?

convertView.setBackgroundDrawable(stateListDrawable); 

但這depricated!如果我用這個。

convertView.setBackground(stateListDrawable); 

我的應用程序崩潰(convertView是RelativeLayout的)也爲convertView.setBackgroundResource 死機一樣你能告訴我,我應該用什麼呢?

+0

崩潰是由拋出的Throwable造成的,但它是什麼Throwable,你只知道,因爲你沒有發佈跟蹤轉儲 – pskink 2014-10-09 19:57:54

回答

1
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { 
    setBackground(); 
} else { 
    setBackgroundDrawable(); 
} 
相關問題