package com.example.alarm01;

import java.net.ServerSocket;
import java.net.Socket;

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.view.View.OnClickListener;

public class MainActivity extends Activity {

	
	private Button button;
	
	Button myButton;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		button = (Button) findViewById(R.id.buttonToast);
		
		myButton = (Button) findViewById(R.id.button1);
		
		button.setOnClickListener(new OnClickListener() {
			 
			  @Override
			  public void onClick(View arg0) {
				  
			     Toast.makeText(getApplicationContext(), 
                               "Button is clicked", Toast.LENGTH_LONG).show();

			  }
		});
		
		
	     Button button1=(Button)findViewById(R.id.button1);
	        button1.setOnClickListener(new OnClickListener(){ // Notre classe anonyme
	            public void onClick(View view){ // et sa méthode !
	            	if (view.getId()==R.id.button1){
	            		Toast.makeText(MainActivity.this,"Bouton 1", Toast.LENGTH_SHORT).show();
	            	}
	            }        	
	        });
		
	      
	        
	        
	       public onClick(View v) 
	        {

	            final int id = v.getId();

	            switch (id) {

	            case R.id.button1:  

	               button1.setText("You clicked on Button 1");       

	                break;

	           

	            

	            }

	        }
	     
	        
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
