• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Drawable --> Picture works, and then it doesn't.

Hi there lovely people,

First of all I want to say thank you for your time reading this.
I'm new to (Android) Programming, been following the Beginner's Tutorial on Udacity and I love it so far.

I have this weird bug happening to me.
I've been working in the activity_main.xml file to ad an picture to my app through the ImageView options.
It's in a RelativeLayout, and I've been adding the picture succesfully to the drawable folder.

I then asign the picture to the ImageView through the [android:src="@drawable/androidparty2"] attribute.

So it al works well. I can build the project succesful, and can launch it succesful on my phone. But after I close the VirtualDevice, the afore mentioned picture dissapears from the 'Design-menu' and all of a sudden the tag "@drawable/androidparty2" turns red in the XML file. (But I've didn't changed any code before or after I build/launched it).

I hope I described it good enough for you guys to understand.

The XML file as written in my file:
----
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">



<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/androidparty2"
/>

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:text="Happy Birthday Ben!"
/>


<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:textSize="36sp"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:text="From Me"
/>
-----

Thanks in advance for your reply, and have a good day!
Cheers!
 
Edit:

I found a temporary fix, but I have to do it manually everytime it occurs. (read: everytime I build the project and run it on the VirtualDevice)

I have to look up the corrosponding drawable folder in Windows Explorer. Then copy the Image outside of that folder. Then change the name to 'androidparty3' then tranfser it back to the Drawable folder and then delete and rewrite the xml attribute to [android:src="@drawable/androidparty3"]
in order to make it work again, until I build the project and run the app again.
 
Well, it weird enough. You shouldn't need to change the image name when you want to change from real device to emulator.
 
Back
Top Bottom