gpt4 book ai didi

java - 启动带有启动画面的应用程序,但是当我运行它时

转载 作者:行者123 更新时间:2023-12-05 00:19:20 31 4
gpt4 key购买 nike

我收到此错误**“java.lang.NullPointerException:尝试在空对象引用上调用虚拟方法'void android.widget.ImageView.setAnimation(android.view.animation.Animation)'”****

public class MainActivity extends AppCompatActivity {

private static int SPLASH_SCREEN = 5000;
Animation topAnim,bottomAnim;
ImageView image;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
topAnim = AnimationUtils.loadAnimation(this, R.anim.top_animation);
bottomAnim = AnimationUtils.loadAnimation(this, R.anim.bottom_animation);


ImageView Logo = findViewById(R.id.Logo);
TextView slogan = findViewById(R.id.slogan);

image.setAnimation(topAnim);
slogan.setAnimation(bottomAnim);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent intent = new Intent(MainActivity.this,Dashboard.class);
startActivity(intent);
finish();
}
},SPLASH_SCREEN);
}
}

最佳答案

变量 image没有初始化!

关于java - 启动带有启动画面的应用程序,但是当我运行它时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63275944/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com