Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6197939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T03:54:34+00:00 2026-05-24T03:54:34+00:00

I just encountered with a problem that I don’t know how to solve. It

  • 0

I just encountered with a problem that I don’t know how to solve. It looks silly but I cannot find a way to fix it.

I have a form in android with several EditText and when you submit the form it checks those EditText and if they have wrong data I change the EditText to red border (applying a ninepatch image).

myEditText.setBackgroundResource(R.drawable.edittext_red);

The problem is, I want to restore android’s default style when the user change the EditText, but I don’t know how to do it. if I do:

myEditText.setBackgroundResource(0);

It will just remove everything and that’s not what I want.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T03:54:36+00:00Added an answer on May 24, 2026 at 3:54 am

    First, before you call setBackgroundResource with your own ninepatch, store the original background of the EditText, like this:

    Drawable originalDrawable = myEditText.getBackground();
    

    Then, if the user entered the wrong data, you can set your red border ninepatch:

    myEditText.setBackgroundResource(R.drawable.edittext_red);
    

    And later, when you want to restore the look of the EditText, use the stored drawable:

    myEditText.setBackgroundDrawable(originalDrawable);
    

    Alternatively you can reference the default Android EditText background directly like this:

    myEditText.setBackgroundResource(android.R.drawable.edit_text);
    

    At androiddrawables you can see how the different drawables look for the different versions of Android, and get their resource identifier. This method should work for all drawables, not just EditText

    These (and other android resources) can also be found on your own system, in the android-sdk folder in

    < path to android-sdk folder>/android-sdk/platforms/android-< API level>/data/res/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've just encountered a weird problem, I'm trying to printf an integer variable, but
I have an app that is nearly finished but encountered an annoying problem. In
I just encountered this article of an extention of css sprites that enables the
I encountered a problem when running some old code that was handed down to
Just looking for the first step basic solution here that keeps the honest people
Just how much slower are events? I have written a streaming XML parser (that
I'm using SubSonic 2.2 and sqlite and have encountered a problem when dealing with
Ok i know this is quite off-topic for programmers but still I need this
I don't do a lot of coding with VB6, but I'm updating an existing
Just what the title says, I need to change the password for an existing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.