![](/img/trans.png)
[英]Difference between setBackgroundDrawable() and setBackground()
[英]how to use setBackgroundDrawable and setBackground?
(在List的getView
內部)我動態創建StateListDrawable
並將其用於setBackgroundDrawable()
:
convertView.setBackgroundDrawable(stateListDrawable);
但是,這簡直是不可思議! 如果我使用這個:
convertView.setBackground(stateListDrawable);
我的應用程序崩潰了。(convertView是RelativeLayout)對convertView.setBackgroundResource
也造成了同樣的崩潰。能告訴我應該使用什么嗎?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setBackground();
} else {
setBackgroundDrawable();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.