package org.crazyit.mixview;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;

/**
 * Description:
 * <br/>site: <a href="http://www.crazyit.org">crazyit.org</a> 
 * <br/>Copyright (C), 2001-2012, Yeeku.H.Lee
 * <br/>This program is protected by copyright laws.
 * <br/>Program Name:
 * <br/>Date:
 * @author  Yeeku.H.Lee kongyeeku@163.com
 * @version  1.0
 */
public class MixView extends Activity
{
	//¶¨ÒåÒ»¸ö·ÃÎÊÍ¼Æ¬µÄÊý×é
	int[] images = new int[]{
		R.drawable.java,
		R.drawable.ee,
		R.drawable.classic,
		R.drawable.ajax,
		R.drawable.xml,
	};
	int currentImg = 0;
	@Override
	public void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		//»ñÈ¡LinearLayout²¼¾ÖÈÝÆ÷
		LinearLayout main = (LinearLayout)findViewById(R.id.root);
		//³ÌÐò´´½¨ImageView×é¼þ
		final ImageView image = new ImageView(this);
		//½«ImageView×é¼þÌí¼Óµ½LinearLayout²¼¾ÖÈÝÆ÷ÖÐ
		main.addView(image);
		//³õÊ¼»¯Ê±ÏÔÊ¾µÚÒ»ÕÅÍ¼Æ¬
		image.setImageResource(images[0]);
		image.setOnClickListener(new OnClickListener()
		{
			@Override
			public void onClick(View v)
			{
				if (currentImg >= 4)
				{
					currentImg = -1;
				}
				//¸Ä±äImageViewÀïÏÔÊ¾µÄÍ¼Æ¬
				image.setImageResource(images[++currentImg]);
			}
		});
	}
}