안드로이드 커스텀 달력 만들기 - ArrayList<HashMap<String, String>> calList
안드로이드/Android Calendar 2019. 10. 20. 11:35안드로이드 달력 만들기 MainActivity.java 와 GridCellAdapter.java 파일에서 아래와 같이 ArrayList 제네릭으로 HashMap<String, String> 을 사용하는 방법이다.
ArrayList<Calendar_Item> calList = new ArrayList<>();
를
ArrayList<HashMap<String, String>> calList = new ArrayList<>();
로 변경하여 코딩하면 어떻게 처리해야 할까?
Calendar_Item 이 HashMap<String, String> 라는 것으로 변경된 것만 살펴보고 수정해주면 된다.
private Calendar_Item calendarItem(String year, String month, String day, int weekday, String color, String name, String key){ |
private HashMap<String, String> calendarItem(String year, String month, String day, int weekday, String color, String name, String key){ |
GridCellAdapter 에서 변경해줄 것은 아래와 같다.
private final ArrayList<Calendar_Item> calList; public GridCellAdapter(Context context, ArrayList<Calendar_Item> list) { String theday = calList.get(position).getDay(); |
private final ArrayList<HashMap<String, String>> calList; public GridCellAdapter(Context context, ArrayList<HashMap<String, String>> list) {
String theday = calList.get(position).get("day"); |
ArrayList<HashMap<String, String>> 를 사용하면 아래와 같은 Calendar_Item Class 를 만들 필요가 없어 코드가 좀 더 간단해질 수 있다.
public class Calendar_Item { |
'안드로이드 > Android Calendar' 카테고리의 다른 글
안드로이드 커스텀 달력 만들기 - GridView 대신 RecyclerView 기반 CalendarAdapter (0) | 2019.10.26 |
---|---|
안드로이드 커스텀 달력 만들기 - LinkedHashMap<String, Calendar_Item> calList (0) | 2019.10.22 |
안드로이드 커스텀 달력 만들기 - Calendar Class 기본 알아보기 (0) | 2019.10.19 |
안드로이드 커스텀 달력 만들기 - GridCellAdapter (0) | 2019.10.19 |
안드로이드 커스텀 달력 만들기 - CalendarHelper (0) | 2019.10.19 |