我目前正在做一个包含自定义警报对话框的android应用程序.它包含一个按钮,但我无法设置按钮的边距.代码如下.setmargin方法不起作用
AlertDialog.Builder myDialog = new AlertDialog.Builder(Login.this);
Button button = new Button(Login.this);
button.setText("Send");
LayoutParams buttonLayoutParams
= new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
button.setLayoutParams(buttonLayoutParams);
resetPassword=editText.getText().toString();
LinearLayout layout = new LinearLayout(Login.this);
layout.setOrientation(LinearLayout.VERTICAL);
layout.addView(textView);
layout.addView(editText);
layout.addView(button);
myDialog.setView(layout);
Run Code Online (Sandbox Code Playgroud) 我目前正在使用Android应用程序,我正在使用该setError方法进行EditText验证.问题是我想改变方法内部文本的颜色.
EditText UserNameEdt, PasswordEdt;
String UserName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login);
UserName = UserNameEdt.getText().toString();
Password = PasswordEdt.getText().toString();
if (UserName.equals("")) {
UserNameEdt.setError("Enter UserName");
}
}
Run Code Online (Sandbox Code Playgroud)
我想将字符串"输入用户名"的颜色更改为黑色,而不是EditText中的文本.