setBackgroundDrawable for ListView in Android

后端 未结 5 902
长发绾君心
长发绾君心 2020-12-14 21:06

How do I set a drawable as the background for a list view in a class?

if (array1.size() < 8)
{
    lv1.setBackgroundDrawable(R.drawable.bgimghs2b);
}
         


        
5条回答
  •  猫巷女王i
    2020-12-14 21:25

    You should use:

    Drawable background = this.getResources().getDrawable(R.drawable.yourBackgroundDrawableID);
    lv.setBackgroundDrawable(background);
    

提交回复
热议问题