健康小检查HealthCheck

\

 

        ActivityMain

 
package org.easy.android.healthCheck;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
public class ActivityMain extends Activity {
 
private Button buttonMarquee;
private ImageButton buttonImage,buttonFigure,buttonFood,buttonSports;
 
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
      
        buttonMarquee=(Button)findViewById(R.id.buttonMarquee);
        buttonFigure=(ImageButton)findViewById(R.id.buttonFigure);
        buttonFood=(ImageButton)findViewById(R.id.buttonFood);
        buttonSports=(ImageButton)findViewById(R.id.buttonSports);
        buttonImage=(ImageButton)findViewById(R.id.buttonImage);
       
        buttonMarquee.setFocusable(true);
        buttonMarquee.requestFocus();
        buttonMarquee.requestFocusFromTouch();
      
        buttonFigure.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
       Intent intent=new Intent();
       intent.setClass(ActivityMain.this,FigureCheck.class);
       startActivity(intent);
       ActivityMain.this.finish();
    
   }
  });
       
        buttonFood.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent=new Intent();
       intent.setClass(ActivityMain.this,FoodCheck.class);
       startActivity(intent);
       ActivityMain.this.finish();
   }
  });
       
        buttonSports.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent=new Intent();
       intent.setClass(ActivityMain.this,SportsCheck.class);
       startActivity(intent);
       ActivityMain.this.finish();
   }
  });
       
       buttonImage.setOnClickListener(new View.OnClickListener() {
   
   @Override
   public void onClick(View v) {
    // TODO Auto-generated method stub
    Intent intent=new Intent();
       intent.setClass(ActivityMain.this,Report.class);
       startActivity(intent);
       ActivityMain.this.finish();
   }
  });
       
    }
   
   
    @Override
 public boolean onCreateOptionsMenu(Menu menu) {
  // TODO Auto-generated method stub
  MenuInflater inflater=getMenuInflater();
  inflater.inflate(R.menu.menu,menu);
  return true;
 }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
  // TODO Auto-generated method stub
  int item_id=item.getItemId();
  
  switch(item_id){
  case R.id.about:
   Dialog dialog=new AlertDialog.Builder(ActivityMain.this)
   .setTitle("关于")
   .setMessage("本程序由Easy制作\nVersion 0.01")
   .setPositiveButton("确定", new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // TODO Auto-generated method stub
     
    }
   }).create();
   
   dialog.show();
   break;
   
  case R.id.exit:
   
   Dialog dialog2=new AlertDialog.Builder(ActivityMain.this)
   .setTitle("退出")
   .setMessage("确定退出程序吗?")
   .setPositiveButton("确定", new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // TODO Auto-generated method stub
     ActivityMain.this.finish();
    }
   }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
    
    @Override
    public void onClick(DialogInterface dialog, int which) {
     // TODO Auto-generated method stub
     
    }
   }).create();
   
   dialog2.show();
   
   
   break;
  
  }
  
  return true;
 }
}



 


转载:http://www.adobex.com/android/source/details/00000392.htm

你可能感兴趣的:(健康小检查HealthCheck)