当前位置: 首页>>代码示例>>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;未经允许,请勿转载。