-1

帮我编码。我不擅长编码 java 和 xml,所以请帮忙。

介绍活动显示 1500 毫秒,然后显示主要活动。我想在介绍活动中添加跳过按钮。

单击跳过按钮时,我想跳到主要活动。

这是我的代码:

MainActivity.java

package com.bedrock.schedule;

import android.R.menu;
import android.R.anim;
import android.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;


public class MainActivity extends Activity {

private BackPressCloseHandler backPressCloseHandler;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //Start Transition Animation
    this.overridePendingTransition(R.anim.startenter, R.anim.startexit);
    setContentView(R.layout.activity_main);

    //Image Animation
    ImageView image = (ImageView)findViewById(R.id.Logo);
    Animation animation=AnimationUtils.loadAnimation(this, R.anim.logoenter);
    image.startAnimation(animation);

    //Image Homepage Link
    image.setOnClickListener(new View.OnClickListener(){
        public void onClick(View v){
            Intent intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.addCategory(Intent.CATEGORY_BROWSABLE);
            intent.setData(Uri.parse("http://young-dong.ms.kr"));
            startActivity(intent);
        }
    });

    //Exit Toast
    backPressCloseHandler = new BackPressCloseHandler(this);
}

//Button Activity Link
public void ClassMain(View view) 
{
    Intent intent = new Intent(MainActivity.this, ClassMain.class);
    startActivity(intent);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
}

//Exit Toast
@Override
public void onBackPressed() {
    //super.onBackPressed();
    backPressCloseHandler.onBackPressed();
}

//Finish Transition Animation
@Override
public void finish() {
    super.finish();
    this.overridePendingTransition(R.anim.endenter, R.anim.endexit);
}

}

IntroActivity.java

package com.bedrock.schedule;

import com.bedrock.schedule.R;

import android.os.Bundle;
import android.os.Handler;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;

public class IntroActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.overridePendingTransition(R.anim.startenter, R.anim.startexit);
    setContentView(R.layout.activity_intro);

    Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        public void run() {
            Intent intent = new Intent(IntroActivity.this, MainActivity.class);
            startActivity(intent);

            //Don't show on back - Finish
            finish();
        }
    }, 1500);
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.intro, menu);
    return true;
}

public void Skip(View view) 
{
    Intent intent = new Intent(IntroActivity.this, MainActivity.class);
    startActivity(intent);
}

}

帮助...如果你能写下代码,请。我陷入了困境,无法发布到应用商店...

4

1 回答 1

0

Very simple, you don't even need to cancel the Runnable. Just add:

private boolean mAlreadyGone;

in the class. Then, in both the Skip() method and the Runnable code, start with:

if (mAlreadyGone)
    return;

mAlreadyGone = true;
于 2014-06-03T15:15:04.680 回答