1

In my code, I have two text boxes that validate input as the user types, and they either display a red cross or a green tick to the right of the box depending on whether the current input is valid or not. I had the red cross image stored in my drawable folder.

Everything was working fine until I decided to get rid of my splash screen. I deleted the class and XML layout file and changed the default activity to 'Login', the one with the tick/cross validation.

Now instead of showing a cross when there is incorrect input, a red square is shown. There are no error messages saying that the image can't be found, but I couldn't see it in the drawable folder, so I copied the image across again with the same name. I can now see the image in the folder after refreshing the project, but still the same thing happens.

I've tried restarting eclipse to no avail. Any ideas?

The android manifest file:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.crowded.media"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:targetSdkVersion="8" 
              android:minSdkVersion="8"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />


    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".Login"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity android:name="RegisteredUser"></activity>
        <activity android:name="OnePennyChallenge"></activity>
        <activity android:name="GamesScreen"></activity>
        <activity android:name="SafeCracker"></activity>

    </application>

</manifest>

The code where I change the image:

    // Add key listener to email edittext and validate as user enters data
    email.addTextChangedListener(new TextWatcher() {

        @Override
        public void afterTextChanged(Editable s) {
            String enteredEmail = email.getText().toString();

            if (validateEmail(enteredEmail) == true) {
                image1.setImageResource(R.drawable.greentick);
            }

            else {
                image1.setImageResource(R.drawable.redcross);
            }
        }

Screen shot showing the res/drawable folder:

enter image description here

And the mysterious red box image:

enter image description here

4

1 回答 1

1

I had a problem like this.You can solve it:
1-Change an Id of a view or layout in one layout that is in your res folder.(for example from "@+id/textView" to "@+id/textView1").
2-Do save all(Ctrl + Shift + s).
3-Change that Id to it's previous value(from "@+id/textView1" to "@+id/textView").
4-Do save all(Ctrl + Shift + s) again.
This must solve your problem.
It may be a bug in eclipse ADT and I heard that it has been resolved in ADT 10.

于 2012-06-19T14:54:02.060 回答