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

  • Home
  • SEARCH
  • 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 8489501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:50:53+00:00 2026-06-10T21:50:53+00:00

I am writing an Android app and have run into a very strange situation.

  • 0

I am writing an Android app and have run into a very strange situation. I have an animation-list xml file that I have created for an animated loading graphic named ‘loading.xml’ and I am setting it as the background for an ImageView in my code. It is something like this:

public void startLoading() {
   if(!isLoading) {
      loading.setBackgroundResource(R.drawable.loading);
      loading.post(new Runnable() {
         public void run() {
            anim = (AnimationDrawable) loading.getBackground();
            anim.start();
         }
      });

      flMask.setBackgroundResource(R.drawable.mask_loading);
      flMask.setVisibility(View.VISIBLE);
      flMask.bringToFront();

      isLoading = true;
   }
}

This works wonderfully with no problems whatsoever. However, if I rename ‘loading.xml’ to ‘anim_loading.xml’ (to keep it inline with my usual naming scheme) I get a force close with

java.lang.ClassCastException: android.graphics.drawable.ColorDrawable

at the line where

anim = (AnimationDrawable)loading.getBackground();

After changing the name, it force closes, and if I change it back to just ‘loading.xml’ it works fine again.

I am really stumped on this one. I have tried creating a completely new file with the correct name, various clean/builds, closing/reopening Eclipse, closing/reopening the AVD, wiping the AVD and reinstalling fresh, I have tried renaming the xml file to something else entirely, and there are no other resources with the same names. So far, nothing has worked outside of leaving the file named ‘loading.xml’, which at least it works, but it is annoying. I haven’t been able to find anyone with the same type of problem, which as vast as SO and the internet are, usually means that it’s something stupid that I have missed somewhere along the line.

Does anyone have any ideas on why it will not let change the name on this file?

  • 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-06-10T21:50:54+00:00Added an answer on June 10, 2026 at 9:50 pm

    After giving up and just leaving it alone for a little while, I just stumbled upon the answer to this question!

    Apparently, there is some sort of bug with Android that causes the first file in the res/drawable directory to be viewed as a ColorDrawable regardless of what it actually is. Before, when I was trying to change the name of the file, the new name put it at the top of the list in the directory and that was enabling this bug to show itself. Without the name change, the top item in my drawable directory just happened to be a ColorDrawable so I never noticed this weird bug until after I tried changing that name.

    To solve the problem (or rather, to work around the problem) I created an empty dummy file in the res/drawable directory named a.xml. As odd as it may sound, it fixed everything!

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

Sidebar

Related Questions

I'm writing an Android app that contains a contact list. The design required me
I am writing an app and I have run into a problem. The first
i'm writing an Android app and i've run into a bit of a roadblock
I'm currently writing a small test Android app, and have run across a small
I am writing a simple Android app and have a database that will send
So I am writing an Android app and want to have a function that
I am currently writing my first Android app and have based most of my
I am writing an app for android and i am trying to have part
Im writing an android app that connects to my own Jersey rest client. HTTP
I am currently writing an Android app that, among other things, uses text information

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.