A lot of posts talk about this probleme, but nobody give the solution to custom the background of seterror() of EditText. It is really possible?
I have this :http://www.romito.fr/public/images/edittext-before.png
->And i would like that : http://www.romito.fr/public/images/edittext-after.png
I already tried all solutions found on stackoverflow... (like How to display input errors in popup? for example)
Thanks
You can try putting your image on the edittext background in the XML code and then do this:
if(some error)
YOUR_IMAGE.setVisibility(View.VISBILE);
else
YOUR_IMAGE.setVisibility(View.GONE);
Related
I have several textviews in my application, sometimes it looks messing, like below:
In normal case, it shoule be like this:
Anyone met this before? Thanks:)
Seemed the customized ROM made some changes to the framework, and the textview buffer is not well cleared before set the new text.
I solve this by setting empty text before setting the real text.
By the way, why my post got the minus point....
I am working with 4.0+ EditText and have to perform validations on a bunch of fields. When a validation fails, I have to change the color of the EditText to red and display a message. Now, I have easily customized the EditText using style and theme, but there is no state for error which I can use in the state list drawable. Any ideas on how this can be achieved?
Why not use EditText.setError(CharSequence error)
The result will look like this
I got it working using LevelListDrawables
I have seen several instances of this question on here and the provided solutions dont seem to work.
My goal : Update the background of my LinearLayout depending on what color i get back from a database query.
What I have so far:
if(teamc=="black"){
drawable = this.getResources().getDrawable(R.drawable.blackbackground);
Toast.makeText(TeamActivity.this,teamc, Toast.LENGTH_LONG).show();
teamColor.setBackgroundDrawable(drawable);
}
Team color is defined as
teamColor = (LinearLayout) findViewById(R.id.teamcolor);
What is happening is that the Toast is appearing just fine but the background is not changing.
Any help would be appreciated.
Are you sure that that toast is showing and not other toast? Because you try to check a String if it's equal to another String by using == operator and that is wrong.
You have to use .equals() method to make a comparison between two Objects.
It is really strange if Toast is working but background is not changing.
Try using teamc.equals("black"){}
or
teamColor.setBackgroundResource(R.drawable.blackbackground);
try to make directly teamColor.setBackgroundResource(R.drawable.blackbackground);
call the invalidate() of the LinearLayout using teamColor object after set the background
teamColor.invalidate();
In my application I use a WebView to display a web page, when the page is scale fits well but now are whites spaces on each side of the page, I can change the background to black color??
I am using using Html.fromHtml to set the corresponding text for a TextView object. Said HTML has url links that I want users to be able to click on and open the browser to that link. I am using LinkMovementMethod to accomplish that fine and dandy. The problem is the link markup is coloring it in the traditional dark blue against a black background, this is bad. I'd like to keep the blackbackground color and change the link color to a lighter blue. How can I do this?
Here is a brief code snippet...
TextView servicesTextView = (TextView)activity.get().findViewById(R.id.ServicesText);
servicesTextView.setText(Html.fromHtml(servicesText));
servicesTextView.setMovementMethod(LinkMovementMethod.getInstance());
Boy, each time I finally write a up a question on StackOverflow, I end up finding the answer myself.
TextView has setLinkTextColor method.
Hey guy's
First of all thanks for reading this.
I'm having trouble to find a way to change my EditText when I loose focus to it.
I would like it to be greyed out when this happens, but I don't want it to be disabled because the user can touch it and edit the text later.
Anyone?
Greetings!
You can set different colors to the text based on an OnFocusChangeListener
Another option is to set a style in xml. See this question for details: Android: change style when focused
To change the opacity, use setAlpha. In this answer I show it how to do it in an animation: Two questions about custom app ui's and AlphaAnimation