OnAnimationEnd不起作用,是的,我已经研究过了

时间:2010-10-19 05:45:33

标签: android

我正在读一本书“语用学:Hello Android” 并逐字复制代码和语法是正确的,因为我没有错误,但它没有做我告诉它在onAnimationEnd上做的事情..它假设带我到我的下一个活动,但因为那不起作用我改变了它像txtView.setText(“ggag”)这样简单的东西 只是为了看它是否正在执行......我注意到这本书的方式略有不同......

    Animation fadein = AnimationUtils.loadAnimation(this, R.anim.fade_in);
    fadein.setAnimationListener(new AnimationListener() { /*im thinking the problem is
     that it does all the work from within the setAnimationLIstener instead of like i
     have seen around where the methods onAnimationEnd , onAnimationRepeat are all
     done seprately outside of the  
      setAnimationListener(new AnimationListener() {..all work is done here??... } */
     @Override
     public void onAnimationEnd(Animation animation) {
      //startActivity(new Intent(splahActivity.this,menuActivity.class));
      //the above line of code was not working so i added the line below 
      //neither executes

                    TextView topLogo = (TextView)findViewById(R.id.lblTop);
      topLogo.setText("dfsgsdfg");

     }

    @Override
    public void onAnimationRepeat(Animation animation) {
      // TODO Auto-generated method stub

    }

    @Override
    public void onAnimationStart(Animation animation) {
     // TODO Auto-generated method stub

    }


    });

所以是的,我的onAnimationEnd代码永远不会被执行:(

2 个答案:

答案 0 :(得分:1)

你有没有打电话给fadein.start()?

onAnimationStart()中的代码(例如记录消息)是否运行?

答案 1 :(得分:0)

我有同样的问题, 我通过在manifest.xml中添加活动标签来解决 希望它适合你...

我的manifest.xml文件现在是:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.androidbook.triviaquiz7"
    android:versionCode="1"
    android:versionName="1.0">
    <application
        android:label="@string/app_name"
        android:debuggable="true"
        android:icon="@drawable/quizicon">
        <activity
            android:name=".QuizSplashActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action
                    android:name="android.intent.action.MAIN" />
                <category
                    android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".QuizGameActivity"></activity>
        <activity
            android:name=".QuizSettingsActivity"></activity>
        <activity
            android:name=".QuizScoresActivity"></activity>
        <activity
            android:name=".QuizHelpActivity"></activity>
        <activity
            android:name=".QuizMenuActivity"></activity>
    </application>
    <uses-sdk
        android:minSdkVersion="7" />
</manifest>

我还在每个活动名称的开头添加了点,消除了所有错误