package com.sf.adapter;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class AdapterDemoActivity extends Activity {
	
	private Button[] btns = new Button[4];
	private int[] btnIds = new int[]{
			R.id.btn1,R.id.btn2,R.id.btn3,R.id.btn4	
	};
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
    	DisplayMetrics displayMetrics = new DisplayMetrics();
		getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
		Constant.displayWidth = displayMetrics.widthPixels;
		Constant.displayHeight = displayMetrics.heightPixels;
		
        for(int i=0;i<btns.length;i++){
        	btns[i] = (Button) findViewById(btnIds[i]);
        	btns[i].setOnClickListener(l);
        }

    }
    
    private OnClickListener l = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			if(v == findViewById(R.id.btn1)){
				startActivity(new Intent(AdapterDemoActivity.this,WeightActivity.class));
			}else if(v == findViewById(R.id.btn2)){
				startActivity(new Intent(AdapterDemoActivity.this,DimenActivity.class));
			}else if(v == findViewById(R.id.btn3)){
				startActivity(new Intent(AdapterDemoActivity.this,DynaActivity.class));
			}else if(v == findViewById(R.id.btn4)){
				startActivity(new Intent(AdapterDemoActivity.this,MutilLayoutActiivty.class));
			}
		}
	};
}