淘宝:模拟实现加载首页前缓冲页面自动跳转(2)


淘宝:模拟实现加载首页前缓冲页面自动跳转(2)
 

 简单的自动页面跳转 附:
Menu的使用方法

1,Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/aab"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <ImageView
        android:id="@+id/welcom_bg"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="@drawable/welcome_bg"
        android:tag="welcome_ImageView@+id/welcom_bg" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/title_30" />

    <ImageView
        android:id="@+id/welcom_q"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@+id/imageView1"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="31dp"
        android:src="@drawable/welcom_q"
        android:tag="welcome_ImageView@+id/welcom_q" />

</RelativeLayout>

 

2.WelcomeActivity.java

package com.hb30;

import java.util.Timer;
import java.util.TimerTask;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class WelcomeActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.welcome);
        final Intent localIntent=new Intent(this,MainActivity.class);
        Timer timer=new Timer();
        TimerTask tast=new TimerTask()
        {
         @Override
         public void run(){
          startActivity(localIntent);
         }
        };
        timer.schedule(tast,3000);
    }
}

 

 

>Menu的使用方法

 

//当客户点击MENU按钮的时候,调用该方法。

 

 

复写public boolean onCreateOptionMenu(Menu menu){

       menu.add(0,1,1,R.string.exit);

       menu.add(0,2,2,R.string.about);

       return super.onCreateOptionsMenu(menu);

}

//当客户点击菜单当中的某一个选项时,会调用该方法

复写onOptionsItemSelected(MenuItem item){

if(item.getItemId()==1){

       finish();

}

return super.onOptionsItemSelected(item);

----------------------------------------

 

你可能感兴趣的:(加载)