我在行setContentView(R.layout.one)中的“one”下面得到一个错误行;错误说“一个无法解决或不是错误字段”。但是,我的one.xml文件中没有显示任何错误。 我甚至多次清理过这个项目,但它仍然存在。 我甚至检查了R.java页面的布局部分,那里的东西也很好。
这是我的xml页面 - “one”:
<?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:id="@+id/rel_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/tapregister" >
<ImageView
android:id="@+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/ashu" />
</RelativeLayout>
和我的班级:
package ashish.com.example.game;
import android.R;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
public class Pageone extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.one);
ImageView imageView=(ImageView)findViewById(R.id.image);
Animation anim1 = new TranslateAnimation(0, 0, 1024, 824);
anim1.setDuration(3000);
anim1.setFillAfter(true);
anim1.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Animation anim2 = new TranslateAnimation(0, 0, 824, 1024);
anim2.setDuration(3000);
anim2.setFillAfter(true);
imageView.clearAnimation();
imageView.startAnimation(anim2);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
imageView.startAnimation(anim1);
}
}
答案 0 :(得分:0)
如果您的Java类在子包中,请确保导入正确的R文件。
import {your top-level package}.R;
例如,如果您的项目包含“com.example.myapp”并且您的活动位于com.example.myapp.activities中,则必须调用
import com.example.myapp.R;
现在,你正在打电话
import android.R;
可能会干扰您的布局。