티스토리 뷰
이번 포스팅에서는 하단 그림과 같이 GridView item 을 동적으로 추가, 수정, 삭제 하는 방법을 알아보자.
참고로, 지난 포스팅에서는 GridView 에 text + image 목록 출력, click 처리, menu 출력 하는 방법에 대해 알아 보았다.
[Android/UI] - GridView (2) - GridView 에 image + text 출력하기
[Android/UI] - GridView (3) - GridView item 의 click 처리하기
[Android/UI] - GridView (4) - GridView item click 시 context menu 출력하기
[Android/UI] - GridView (5) - GridView item long click 시 popup menu 출력하기
Item 삽입
Adapter 에 지정한 grid list 에 아이템을 추가한다.
아이템 추가 후 꼭 adpater 의 "notifyDataSetChanged" 를 호출해야 grid view 에 반영된다.
Item 수정
Adapter 에 지정한 grid list 에서 원하는 위치의 아이템을 수정한다.
현재 선택된 아이템 위치는 grid view 의 "getCheckeditemPosition" 을 이용하면 된다.
삽입과 마찬가지로 수정 후 꼭 adpater 의 "notifyDataSetChanged" 를 호출해야 grid view 에 반영된다.
Item 삭제
Adapter 에 지정한 grid list 에서 원하는 위치의 아이템을 삭제한다.
현재 선택된 아이템 위치는 grid view 의 "getCheckeditemPosition" 을 이용하면 된다.
삽입, 수정과 마찬가지로 수정 후 꼭 adpater 의 "notifyDataSetChanged" 를 호출해야 grid view 에 반영된다.
Source code
https://github.com/parkho79/GridView_5
'Android > UI' 카테고리의 다른 글
RecyclerView (1) (0) | 2021.02.17 |
---|---|
GridView (7) - GridView 에 header, footer 달기 (0) | 2021.02.17 |
GridView (5) - GridView item long click 시 popup menu 출력하기 (0) | 2021.02.17 |
GridView (4) - GridView item click 시 context menu 출력하기 (0) | 2021.02.15 |
GridView (3) - GridView item 의 click 처리하기 (0) | 2021.02.09 |
- Total
- Today
- Yesterday
- StartService
- 무료 채굴
- android intent
- 안드로이드 인텐트
- StringUtils
- android flag activity
- task
- onCreateContextMenu
- 앱테크
- 리워드 어플
- Intent
- 안드로이드 서비스
- WEMIX
- registerForContextMenu
- onContextItemSelected
- p2e
- bindservice
- 리워드앱
- BroadcastReceiver
- RoomDatabase
- mPANDO
- 무료채굴
- Android Service
- android activity flag
- M2E
- android task
- notifyDataSetChanged
- 채굴앱
- 앱테크 추천
- task 생성
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |