package com.example.simplecontacts;
import com.example.simplecontacts.Person;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;

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

public class MainActivity extends AppCompatActivity {
    private ListView peopleListView;
    private PersonAdapter peopleAdapter;
    private String[] peoples={"柯文哲","梁非凡","蔡中文","阿扁","小熊","刘醒"};
    private String[] telnumber={"13378458180","13378458181","13378458182","13378458183","13378458184","13378458185"};
    private int[] peoImgs={R.mipmap.tx1,R.mipmap.tx2,R.mipmap.tx3,R.mipmap.tx4,R.mipmap.tx5,R.mipmap.tx6};
    private List<Person> persons=new ArrayList<Person>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        peopleListView = findViewById(R.id.spListView);
        initDataPersons();
        peopleAdapter = new PersonAdapter(persons,MainActivity.this);
        peopleListView.setAdapter(peopleAdapter);
    }
    private void initDataPersons(){
        for(int i=0;i<peoples.length;i++){
            Person person=new Person(peoples[i],peoImgs[i],telnumber[i]);
            persons.add(person);
        }
    }
}