所以我有一个LinearLayout和4个EditText-s,其中XML带有灰色提示颜色.我有一个按钮,可以将新的EditText-s动态添加到LinearLayout.问题是当我使用setHint(“ text”)时,它将使新创建的视图的提示颜色变为黑色.
还尝试过setHintTextColor(),但是它通过设置自定义颜色对我有用.是否可以通过setHintTextColor()设置默认的提示颜色?或某种方法在调用时会执行此操作?
代码如下:
private EditText createNewTextView(String text) {
++x;
final ActionBar.LayoutParams lparams = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT, ActionBar.LayoutParams.WRAP_CONTENT);
final EditText editText = new EditText(this);
editText.setLayoutParams(lparams);
editText.setHint("Name" + x);
editText.setHintTextColor(getResources().getColor(R.color.hintcolor));
return editText;
}
附:我用一种新的颜色制成了一种叫做“提示色”的颜色
我一直在寻找解决方案,但是没有什么对我有帮助,或者我只是不理解.我是android和编程方面的新手,所以请不要判断,请解释一下.非常感谢