java - Intent 的动画监听器错误

标签 java android

此代码应该在单击按钮时执行我设置的动画,等待动画完成,然后加载新 Activity 。当我尝试添加监听器时,我的 Intent 构造函数出现错误。任何帮助都会很棒。

public void onClick (View v)  {
       switch (v.getId()){
           case R.id.buttonStart:
               wobble.setAnimationListener(new Animation.AnimationListener() {
                   @Override
                   public void onAnimationStart(Animation animation) {
                       buttonStart.startAnimation(wobble);
                   }

                   @Override
                   public void onAnimationEnd(Animation animation) {
                       startActivity(new Intent(this,CityRendActivity.class));
                   }

                   @Override
                   public void onAnimationRepeat(Animation animation) {

                   }
               });



               break;
       }
}
}

最佳答案

看起来您在 onAnimationEnd 中传递的 this 是正在创建的 AnimationListener。您需要指定要传递给 Intent 构造函数的 this 是您的 Activity :

@Override
public void onAnimationEnd(Animation animation) {
    startActivity(new Intent(MyActivity.this, CityRendActivity.class));
}

关于java - Intent 的动画监听器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34774680/

相关文章:

Java MySQL 分页

java - 在 actionPerformed 中运行 "this"方法 - JButton?

java - 如何让Activity运行到服务

android - UNINSTALL_SHORTCUT 操作无效 |安卓

android - ActionBarSherlock 不支持浅色主题提醒对话框?

android - ListView 的动态行布局

java - java中通过变量名调用对象方法

java - Android 中的正则表达式帮助

android - Fabric BETA 添加了 TwitterAdvertisingInfoPreferences 应用程序的数据

java - 自定义 ArrayAdapter 中未出现字体