80,471
社区成员




package com.example.jump;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Handler.Callback;
public class WelcomePage extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome);
mHandler.sendEmptyMessageDelayed(GOTO_MAIN_ACTIVITY, 3000);
}
protected final int GOTO_MAIN_ACTIVITY = 0;
Handler mHandler = new Handler(new Callback() {
public boolean handleMessage(android.os.Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent();
intent.setClass(WelcomePage.this, Page1.class);
startActivity(intent);
finish();
break;
default:
break;
}
return true;
}
});
}
package com.example.jump;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Page1 extends Activity {
private Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page1);
btn1=(Button) findViewById(R.id.btn_1);
btn1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent intent = new Intent(Page1.this,Page2.class);
startActivity(intent);
}});
}
}
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.demo.welcome.WelComeActivity"
android:windowSoftInputMode="stateAlwaysHidden|adjustResize" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.demo.MainActivity"
android:screenOrientation="portrait" >
</activity>
public class WelComeActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mHandler.sendEmptyMessageAtTime(GOTO_MAIN_ACTIVITY, 3000);//3秒跳转
}
private static final int GOTO_MAIN_ACTIVITY = 0;
private Handler mHandler = new Handler(){
public void handleMessage(android.os.Message msg) {
switch (msg.what) {
case GOTO_MAIN_ACTIVITY:
Intent intent = new Intent();
intent.setClass(WelComeActivity.this, MainActivity.class);
startActivity(intent);
finish();
break;
default:
break;
}
};
};