views:

139

answers:

1

I am still trying to figure out frame animation, but I need to use IDs. I don't get it... I get the wierdest errors...

<?xml version="1.0" encoding="UTF-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false" android:id="@+id/carrotsmileanim"> 
<item android:drawable="@drawable/carrotsmile" android:duration="2000" /> 
<item android:drawable="@drawable/carrotblink" android:duration="2000" /> 
<android:id="@+id/carrotsmileanim></android:id>
</animation-list>

In the ID section the error is: "

android:id" must be followed by either attribute specifications, ">" or "/>"

My Java code is this:

package com.example.carrottest2;

import android.app.Activity;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.R;

public class Carrottest2 extends Activity {
/** Called when the activity is first created. */

AnimationDrawable mainanimation; 

public void onCreate(Bundle icicle) {  
     super.onCreate(icicle);  

     ImageView carrotsmile = (ImageView) findViewById(R.id.carrotblink);
     rocketImage.setBackgroundResource(R.drawable.rocket_thrust);
     c = (AnimationDrawable) rocketImage.getBackground();
     carrotsmileanim.start();

The tutorial frame animation android IDs are still there, I never changed them, but it does not recognize carrotblink, rocketImage, rocketthrust, c, carrotsmileanim, and says "cannot be resolved or is not a field." error.

Can someone help me with this? Which is supposed to go where?

Is main.xml involved in this? I know there is supposed to be an imageview somewhere, but where?

A: 

Matt Huggins is right. What you've posted isn't valid XML because of the missing quotation mark. But also, I don't think 'id' is a tag that is used by android. It's an attribute (as you used it, correctly, on the root element) but AFAIK there is no <android:id> element. When you add the id attribute to something, it automatically creates that id, and makes it accessible via your generated R file.

MatrixFrog
I realize, but id should be next to imageview and findviewbyid, setbackgroundesource, animationdrawable, getbackground, and start? Also, eclipse will not recognize the second quotation! Why is this?
Mia
I'm not sure what your comment is about. What do you mean Eclipse won't recognize your quotation mark?
MatrixFrog
Yeah! It wont recognize both of them now!
Mia