因为我在用
EditText et=new EditText(this);
locationEditText.setBackgroundDrawable(et.getBackground());
但是 setBackgroundDrawable(Drwable)
在 Api 16 中被弃用,因为不能使用 setBackground(Drwable)
因为它是在 api 16 中添加的并且我使用的是早期版本比那个
所以只剩下两个功能留给我了
是:setBackgroundColor(int color)
和setBackgroundResource(int resid)
那么Holo Light Theme中如何设置为默认的EditText
呢?
最佳答案
使用 setBackground(Drawable drawable)
做与 setBackgroundDrawable(Drwable) 相同的工作。
编辑:感谢 Warpzit 提供此代码 (source) :
EditText et=new EditText(this);
int sdk = android.os.Build.VERSION.SDK_INT;
if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) {
setBackgroundDrawable(et.getBackground());
} else {
setBackground(et.getBackground());
}
您可以找到更多信息 in this question
关于java - 如何以编程方式将 EditText 背景设置为 Holo 主题 Api 11-17 Android 中的默认背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18100475/