package com.androidbegin.buttonclicktutorial;


import java.util.ArrayList;
import java.util.List;

import android.app.ActionBar.LayoutParams;
import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.Activity;
import android.content.ContentValues;
import android.content.Intent;
import android.database.Cursor;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.provider.MediaStore;
import android.util.Log;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnTouchListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;



public class AddEvent extends Activity 
{
	
	private EditText txt_id, txt_name, txt_from_date, txt_to_date, txt_datetime, txt_status, txt_created_time, txt_modified_time, txt_rule, txt_interval, txt_sound, txt_created_at;
	private EditText txt_info;
	
	private CheckBox chk1,chk2;
	private Button btn_update_alarm;  
	
	DB_calendar db;
	
	final String EXTRA_POSITION = "extra_position";
	final String EXTRA_ID = "extra_id";
	
	String id_alarm = "";
		
	Button  button1, button2, button3, button20;
	
	Drawable back;
	int flag = 0;
	
	boolean isPressed = false;

	
	@Override
	protected void onCreate(Bundle savedInstanceState) 
	{		
			super.onCreate(savedInstanceState);
			setContentView(R.layout.test02);
			
			// bouton return sans action bar
			ActionBar actionBar = getActionBar();
			actionBar.setDisplayHomeAsUpEnabled(true);
			
			remplir_spinner();

	}
	
	
	public void remplir_spinner()
	{
		
		// Spinner element
	      final Spinner spinner = (Spinner) findViewById(R.id.spinner);
	      
	      // Spinner click listener
	      //spinner.setOnItemSelectedListener(this);
	      
	      // Spinner Drop down elements
	      List<String> categories = new ArrayList<String>();
	      categories.add("Automobile");
	      categories.add("Business Services");
	      categories.add("Computers");
	      categories.add("Education");
	      categories.add("Personal");
	      categories.add("Travel");
	      
	      // Creating adapter for spinner
	      ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, categories);
	      
	      // Drop down layout style - list view with radio button
	      dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
	      
	      
	      //spinner.setOnItemSelectedListener((OnItemSelectedListener) this);
	      
	   
	     // spinner.setOnClickListener((OnClickListener) this);
	      
	      spinner.setOnItemSelectedListener(new OnItemSelectedListener() 
	      {
	    	  
	    	  @Override
	    	  public void onItemSelected(AdapterView<?> parent, View view,
	    	  int position, long id) {
	    	  
	    	  String SpinnerValue = (String)spinner.getSelectedItem(); 
	    	  
	    	  Toast.makeText(getApplicationContext(), SpinnerValue , Toast.LENGTH_SHORT).show();
	    	  }
	    	  
	    	  @Override
	    	  public void onNothingSelected(AdapterView<?> parent) {
	    	  // TODO Auto-generated method stub
	    	  
	    	  }
	    	  });
	      
	      
	      
	      // attaching data adapter to spinner
	      spinner.setAdapter(dataAdapter);
		
	}
	
	public boolean onOptionsItemSelected(MenuItem item)
	{
	    Intent myIntent = new Intent(getApplicationContext(),MainActivity.class);
	    startActivityForResult(myIntent, 0);
	    return true;
	}

	 
	public void onItemSelected(AdapterView parent, View view, int position, long id) 
	{ 
		
		String item = parent.getItemAtPosition(position).toString(); // Showing selected spinner item in toast 
		Toast.makeText(parent.getContext(), "Selected Country: " + item, Toast.LENGTH_LONG).show();
		
	}
	 		
	


		
}
