package com.example.listview;


import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;

public class MainActivity extends Activity {
	 
    ListView mListView;
    String[] prenoms = new String[]{
         "Antoine", "Benoit", "Cyril", "David", "Eloise", "Florent",
         "Gerard", "Hugo", "Ingrid", "Jonathan", "Kevin", "Logan",
         "Mathieu", "Noemie", "Olivia", "Philippe", "Quentin", "Romain",
         "Sophie", "Tristan", "Ulric", "Vincent", "Willy", "Xavier",
         "Yann", "Zoé"
    };
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
 
        mListView = (ListView) findViewById(R.id.listView);
 
        //android.R.layout.simple_list_item_1 est une vue disponible de base dans le SDK android,
        //Contenant une TextView avec comme identifiant "@android:id/text1"
 
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(MainActivity.this,   android.R.layout.simple_list_item_1, prenoms);
        mListView.setAdapter(adapter);
   
        setTitle("TestIconizedListView");
    
        mListView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id)
            {
               
            	
            	
	        	
            	// Intent i = new Intent(this, Class.forName(mActivities[position]));
                // startActivity(i);
            	//intent.putExtra("list", list);
	             
            	//Document document =      (Document)mListView.getAdapter().getItem(position);
            	//	String name = document.getName();
            	
            	String item_valeur = (String) (  mListView.getItemAtPosition(position ));
            	
	             Intent element_Intent = new Intent(getBaseContext(), reception.class);
	             element_Intent.putExtra("send", item_valeur); 
	             startActivity(element_Intent);
	             
            	
                //String item = ((TextView)view).getText().toString();
                //Toast.makeText(getBaseContext(), item, Toast.LENGTH_LONG).show();
               
            }
        });
    
    
    
    
    }
    
    
    
    
}