使用Android Id';s
我仍在尝试找出帧动画,但我需要使用ID。我发现以下错误:使用Android Id';s,android,eclipse,sdk,Android,Eclipse,Sdk,我仍在尝试找出帧动画,但我需要使用ID。我发现以下错误: <?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="@drawabl
<?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>
我的代码:
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();
教程框架动画android ID仍然存在,我从未更改过它们,但它无法识别这些,它给了我一个“无法解析或不是字段”错误
哪个应该去哪里
是否涉及main.xml?我知道某处应该有一个图像视图,但我不确定在哪里。马特·哈金斯是对的。由于缺少引号,您发布的内容不是有效的XML。但是,我也不认为id是安卓使用的标签。它是一个属性(正如您在根元素上正确使用的那样),但是AFAIK没有
元素。当您将id
属性添加到某物时,它会自动创建该id,并通过生成的R
文件使其可访问。马特·哈金斯是对的。由于缺少引号,您发布的内容不是有效的XML。但是,我也不认为id是安卓使用的标签。它是一个属性(正如您在根元素上正确使用的那样),但是AFAIK没有
元素。当您将id
属性添加到某个对象时,它会自动创建该id,并通过生成的R
文件使其可访问。我意识到,但id应该位于imageview和findviewbyid、setbackgroundesource、animationdrawable、getbackground和start旁边?另外,eclipse将不会识别第二个引号!这是为什么?我不知道你的评论是关于什么的。你说Eclipse不会识别你的引号是什么意思?我知道,但id应该在imageview和findviewbyid、setbackgroundesource、animationdrawable、getbackground和start旁边?另外,eclipse将不会识别第二个引号!这是为什么?我不知道你的评论是关于什么的。你说Eclipse不会识别你的引号是什么意思?
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();