Android-獲取資源Resources,設置Background

Android中獲取資源的代碼如下:
1 //獲取資源
2 Resources res = getBaseContext().getResources(); 
3 Drawable draw=res.getDrawable(R.drawable.icon);   

設置背景圖如下:
1 //設置linearLayout的背景圖,將Drawable對象放進去
2 linearLayout.setBackgroundDrawable(draw);

 

摘自 Bumblebee

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *