當前位置: 首頁>>代碼示例>>Java>>正文


Java TextView.setError方法代碼示例

本文整理匯總了Java中android.widget.TextView.setError方法的典型用法代碼示例。如果您正苦於以下問題:Java TextView.setError方法的具體用法?Java TextView.setError怎麽用?Java TextView.setError使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.TextView的用法示例。


在下文中一共展示了TextView.setError方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addGesture

import android.widget.TextView; //導入方法依賴的package包/類
@SuppressWarnings({"UnusedDeclaration"})
public void addGesture(View v) {
    if (mGesture != null) {
        final TextView input = (TextView) findViewById(R.id.gesture_name);
        final CharSequence name = input.getText();
        if (name.length() == 0) {
            input.setError(getString(R.string.error_missing_name));
            return;
        }

        final GestureLibrary store = GestureBuilderActivity.getStore();
        store.addGesture(name.toString(), mGesture);
        store.save();

        setResult(RESULT_OK);

        final String path = new File(Environment.getExternalStorageDirectory(),
                "gestures").getAbsolutePath();
        Toast.makeText(this, getString(R.string.save_success, path), Toast.LENGTH_LONG).show();
    } else {
        setResult(RESULT_CANCELED);
    }

    finish();
    
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:27,代碼來源:CreateGestureActivity.java

示例2: validateId

import android.widget.TextView; //導入方法依賴的package包/類
protected ValidationResult validateId(String dataString, View ui, int textViewId) {

        TextView textView = (TextView) ui.findViewById(textViewId);

        if (TextUtils.isEmpty(dataString)) {
            textView.setError(null);
            return new ValidationResult(textView, ValidationResult.Validity.UNKNOWN);

        } else {
            if (dataString.length() != 6) {
                textView.setError("Please type in 6 digits ID");
                return new ValidationResult(textView, ValidationResult.Validity.ERROR);
            }
            try {
                Integer.parseInt(dataString);
            } catch (Throwable t) {
                textView.setError("Please type in 6 digits ID");
                return new ValidationResult(textView, ValidationResult.Validity.ERROR);
            }
            textView.setError(null);
            return new ValidationResult(textView, ValidationResult.Validity.VALID);
        }
    }
 
開發者ID:vicianm,項目名稱:sticky-linear-layout-demo,代碼行數:24,代碼來源:UserValidator.java

示例3: validateZip

import android.widget.TextView; //導入方法依賴的package包/類
protected ValidationResult validateZip(String dataString, View ui, int textViewId) {

        TextView textView = (TextView) ui.findViewById(textViewId);

        if (TextUtils.isEmpty(dataString)) {
            textView.setError(null);
            return new ValidationResult(textView, ValidationResult.Validity.UNKNOWN);

        } else {
            if (dataString.length() != 5) {
                textView.setError("Please type in 5 digit ZIP code");
                return new ValidationResult(textView, ValidationResult.Validity.ERROR);
            }
            try {
                Integer.parseInt(dataString);
            } catch (Throwable t) {
                textView.setError("Please type in 5 digit ZIP code");
                return new ValidationResult(textView, ValidationResult.Validity.ERROR);
            }
            textView.setError(null);
            return new ValidationResult(textView, ValidationResult.Validity.VALID);
        }
    }
 
開發者ID:vicianm,項目名稱:sticky-linear-layout-demo,代碼行數:24,代碼來源:AddressValidator.java

示例4: checkEmptyField

import android.widget.TextView; //導入方法依賴的package包/類
/**
 * Check if the the textview is empty
 *
 * @param ctx  Current context
 * @param view Le Current TextView
 */
public static void checkEmptyField(Context ctx, TextView view) {
  if (view.getText().toString().trim().length() == 0) {
    view.setError(view.getResources().getString(R.string.empty_field));
  } else {
    view.setError(null);
  }
}
 
開發者ID:goutfeb,項目名稱:ElephantAsia,代碼行數:14,代碼來源:StaticTools.java

示例5: setTotal

import android.widget.TextView; //導入方法依賴的package包/類
public void setTotal(TextView totalText, Total total) {
    if (total.isError()) {
        setTotalError(totalText);
    } else {
        setAmountText(totalText, total);
        totalText.setError(null);
    }
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:9,代碼來源:Utils.java

示例6: addAmountAndErrorNode

import android.widget.TextView; //導入方法依賴的package包/類
private void addAmountAndErrorNode(Total total) {
    TextView data = x.addInfoNode(layout, -1, R.string.not_available, "");
    Drawable dr = getResources().getDrawable(R.drawable.total_error);
    dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
    if (total.currency == Currency.EMPTY) {
        data.setText(R.string.currency_make_default_warning);
    } else {
        data.setText(total.getError(AbstractTotalsDetailsActivity.this));
    }
    data.setError("Error!", dr);
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:12,代碼來源:AbstractTotalsDetailsActivity.java

示例7: setError

import android.widget.TextView; //導入方法依賴的package包/類
public static void setError(TextView textView, String errorMessage) {
    TextInputLayout textInputLayout = getTextInputLayout(textView);
    if (textInputLayout != null) {
        textInputLayout.setErrorEnabled(!TextUtils.isEmpty(errorMessage));
        textInputLayout.setError(errorMessage);
    } else {
        textView.setError(errorMessage);
    }
}
 
開發者ID:Ilhasoft,項目名稱:data-binding-validator,代碼行數:10,代碼來源:EditTextHandler.java

示例8: setTotalError

import android.widget.TextView; //導入方法依賴的package包/類
private void setTotalError(TextView totalText) {
    totalText.setText(R.string.not_available);
    Drawable dr = context.getResources().getDrawable(R.drawable.total_error);
    dr.setBounds(0, 0, dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
    totalText.setError(totalText.getText(), dr);
}
 
開發者ID:tiberiusteng,項目名稱:financisto1-holo,代碼行數:7,代碼來源:Utils.java

示例9: onClick

import android.widget.TextView; //導入方法依賴的package包/類
public void onClick(View v) {
	
	
	v.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING);
	
	switch (v.getId()) {
		case R.id.fragment_forgot_password_submit:
			
		boolean validForm = true;
		TextView forgotEmail = (TextView) getActivity().findViewById(R.id.fragment_forgot_password_email_address);
		
		if (forgotEmail .getText().length() == 0) {
			forgotEmail.setError("Please enter your e-mail address.");
			forgotEmail.requestFocus();
			validForm  = false;
		} else if (!android.util.Patterns.EMAIL_ADDRESS.matcher(forgotEmail.getText()).matches()) {
			forgotEmail.setError("Please enter valid e-mail address.");
			forgotEmail.requestFocus();
			validForm = false;
		}
		
		
		if (validForm) {
			InputMethodManager inputManager = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
			inputManager.hideSoftInputFromWindow(forgotEmail.getWindowToken(), 0);

			mResetPassTask = new ResetPasswordTask().execute(new String[]{forgotEmail.getText().toString()});
		}
			
			
		break;

	}
	
}
 
開發者ID:Greenstand,項目名稱:treetracker-android,代碼行數:36,代碼來源:ForgotPasswordFragment.java


注:本文中的android.widget.TextView.setError方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。