package com.example.menu;

import java.util.ArrayList;

import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemLongClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ListViewActivity  	extends BaseMenuActivity 
								implements OnItemClickListener{
	
	private ArrayList<String> listItemData1=new ArrayList<String>();
	private  ArrayList<Individu> liste;
	private ApplicationDataShare app;
	
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_list_view);
        
        app=ApplicationDataShare.getInstance();
        liste=app.getListeIndividu();
        
        updateList();
        ArrayAdapter defaultAdapter=new  ArrayAdapter(this,android.R.layout.simple_list_item_1,listItemData1);
        // STEP 3: on recupere la ListView depuis xml
        ListView viewListEvent=(ListView)findViewById(R.id.lv_individu);
        // STEP 4: j'affecte à ma vue l'adapter 
        viewListEvent.setAdapter(defaultAdapter);
        viewListEvent.setOnItemClickListener(this);
        
    }
    
   private void updateList(){
	   for (Individu idv:liste){
		   String texte=idv.getPrenom()+" "+idv.getNom();
		   this.listItemData1.add(texte);
	   }
	   
   }

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long id) {
	// TODO Auto-generated method stub
	app.setIndividu(liste.get(position));
}


}
