---
title: "EditText的错误信息"
author: "epy"
date: "2015-12-02T18:06:33Z"
tags: []
categories: ["移动开发"]
slug: "edittext"
draft: false
lastmod: "2015-12-02T18:06:32Z"
id: 2261167
url: "https://epy.iteye.com/blog/2261167"
---

EditText可以通过setError来显示错误信息

![](http://dl2.iteye.com/upload/attachment/0113/4867/b09d6a31-8203-371a-9fa9-6077b73151c7.jpg)  
 

通过设置application或activity的android:theme属性，可以修改错误信息的样式，但是不能自己定义错误信息的样式。

[http://stackoverflow.com/questions/13874197/androiderrormessagebackground-getting-no-resource-found-error-in-styles-xml](http://stackoverflow.com/questions/13874197/androiderrormessagebackground-getting-no-resource-found-error-in-styles-xml)

[https://code.google.com/p/android/issues/detail?id=55879](https://code.google.com/p/android/issues/detail?id=55879)

Ther is no way to override standard Theme attributes errorMessageBackground and errorMessageAboveBackground

 &lt;!-- Application theme. --&gt;

    &lt;style name="AppTheme" parent="android:Theme.Holo.Light" &gt;

        &lt;item name="errorMessageBackground"&gt;@drawable/ic\_launcher&lt;/item&gt;

        &lt;item name="errorMessageAboveBackground"&gt;@drawable/ic\_launcher&lt;/item&gt;

    &lt;/style&gt;

Show error in Eclipse

error: Error: No resource found that matches the given name: attr 'errorMessageAboveBackground'.