Context가져오기

0

안드로이드

목록 보기
11/19

이것저것을 사용할때 현재 Context나 Activty가 필요할때가 있다.

초급개발자한테는 이게 가끔가다가 어렵다...

Fragment

getActivty()를 이용하자. Fragment는 사실 Activity 에대한 하위 layout이라고 생각하면 편하다.
상위 Activity나 Context를 쉽게 가져올수 있다.

Adapter

Adapter에서 필요한 Context나 Activity를 가져올때
holder.item_notice_title.getContext() View를 이용해 Context를 가져올수있다.

혹시나 나중에 추가 사항이 있으면 적겠다.

profile
쉽게 가르칠수 있도록 노력하자

0개의 댓글