你好伙计们认真对待android很新,我希望你能帮我解决这个问题...编辑它
public class LoginFragment extends Fragment implements OnClickListener {
private EditText login, password, domain;
private ImageView apply;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.setup_generic_login, container, false);
login = (EditText) view.findViewById(R.id.setup_username);
password = (EditText) view.findViewById(R.id.setup_password);
domain = (EditText) view.findViewById(R.id.setup_domain);
apply = (ImageView) view.findViewById(R.id.setup_apply);
apply.setOnClickListener(this);
return view;
}
@Override
public void onClick(View v) {
int id = v.getId();
if (id == R.id.setup_apply) {
if (login.getText() == null || login.length() == 0 || password.getText() == null || password.length() == 0 || domain.getText() == null || domain.length() == 0) {
Toast.makeText(getActivity(), getString(R.string.first_launch_no_login_password), Toast.LENGTH_LONG).show();
return;
}
SetupActivity.instance().genericLogIn(login.getText().toString(), password.getText().toString(), domain.getText().toString());
}
}}
我想为域分配一个默认字符串,(例如domain =“pearlcom.au.ug”) 我编辑了xml文件并删除了EditText字段
请不要关闭我的帖子.......请忽略! 感谢那些帮助我的人!
答案 0 :(得分:1)
你可以这样做:
机器人:文本=" @串/域"并指定您在strings.xml中选择的任何域字符串,并将其作为默认值。
- >如果您想要显示占位符,请包含
机器人:提示=" @串/ enter_domain"
答案 1 :(得分:0)
只需在onCreate()中执行此操作:
domain.setText("pearlcom.au.ug");