Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想textview在android中设置运行时背景在这里你可以看到我有一个image运行时设置这不是修复所以我想textview用不同颜色的文本更改运行时背景和当前位置
textview
image
holder.textmenu.setBackgroundDrawable(R.Drawable.imagename) // gives error holder.textmenu.setBackgroundColor(R.color.color_orange);`
它应该是
holder.textmenu.setBackgroundResource(R.Drawable.imagename)
要将图像设置为您的 textview 背景,请使用youtextview.setBackgroundResource(R.drawable.yourimage);
youtextview.setBackgroundResource(R.drawable.yourimage);