开发者

Using Android Id's?

开发者 https://www.devze.com 2023-01-08 06:51 出处:网络
I am still trying to figure out frame animation, but I 开发者_Python百科need to use IDs. I get these errors:

I am still trying to figure out frame animation, but I 开发者_Python百科need to use IDs. I get these 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 code:

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 these, and it gives me a "cannot be resolved or is not a field." error.

Which is supposed to go where?

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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消