帮我编码。 我不擅长编写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);
}
}
帮助...如果您可以写下代码,请。 我陷入了困境,无法向应用商店发布......
答案 0 :(得分:0)
很简单,你甚至不需要取消Runnable。只需添加:
private boolean mAlreadyGone;
在课堂上。然后,在Skip()
方法和Runnable代码中,以:
if (mAlreadyGone)
return;
mAlreadyGone = true;