Code example for EditText

Methods: getTextsetError

0
	private void onSendCommandClicked() { 
		Log.v(TAG, "Save button clicked");
		if (validate()) { 
			if (isUsingWifi()) { 
				sendCommand(mHostText.getText().toString(),
						Integer.parseInt(mPortText.getText().toString()),
						mPasswordText.getText().toString(),
						(CmusCommand) mCommandSpinner.getSelectedItem());
			} else { 
				alert("Could not send command", "Not sending command: not on Wifi."); 
			} 
		} 
		// finish(); 
	} 
 
	private void alert(String title, String message) {
		Log.v(TAG, message);
		new AlertDialog.Builder(this)
				.setMessage(message)
				.setTitle(title).show();
	} 
 
	private boolean validate() { 
		boolean valid = true;
 
		if (!Validator.validateString(mHostText.getText().toString())) {
			valid = false;
			mHostText.setError("the hostname is not valid");
		} else { 
			mHostText.setError(null);
		} 
 
		if (!Validator.validateInteger(mPortText.getText().toString())) {
			valid = false;
			mPortText.setError("the port is not valid");
		} else { 
			mPortText.setError(null);
		} 
 
		if (!Validator.validateString(mPasswordText.getText().toString())) {