package com.javacodegeeks.android.example.androidmultitouchlist;


import java.util.ArrayList;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {
 ListView listview;
 MyArrayAdapter studentArrayAdapter;
 ArrayList<Student> studentArray = new ArrayList<Student>();

 @Override
 protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  
  studentArray.add(new Student("Nick", "18", "1st Street"));
  studentArray.add(new Student("John", "18", "2st Street"));
  studentArray.add(new Student("Anthony", "19", "3rd Street"));
  studentArray.add(new Student("James", "20", "5th Street"));
  studentArray.add(new Student("Jack", "20", "6th Street"));
  studentArray.add(new Student("Jeremy", "20", "7th Street"));
  studentArray.add(new Student("Long", "21", "1st Street"));
 
  studentArrayAdapter = new MyArrayAdapter(MainActivity.this, R.layout.list_item, studentArray);
  listview = (ListView) findViewById(R.id.listView);
  listview.setItemsCanFocus(false);
  listview.setAdapter(studentArrayAdapter);
 
  listview.setOnItemClickListener(new OnItemClickListener() {

   @Override
   public void onItemClick(AdapterView<?> parent, View v,
     final int position, long id) {
    
    Toast.makeText(MainActivity.this,
      "List Item Clicked:" + position, Toast.LENGTH_LONG)
      .show();
   }
  });

 }

}
