안드로이드 Inflater

Intro

Inflater 이란

Inflater

xml에 정의된 위젯을 메모리에 형성하는 과정을 inflation이라 하며 inflater는 xml로 정의된 view를 객체화 시키는 용도이다.

Inflater 는 성능상의 문제 때문에 컴파일 타임에 완성된 xml에 대해서만 적용 가능하다. (R. 으로 시작되는 resource 파일들만 inflate 가능)

사용 방법

inflater 얻어오기

LayoutInflater inflater = (LayoutInflater) getSystemService( Context.LAYOUT_INFLATER_SERVICE );

xml 인플레이션

LinearLayout linearLayout = (LinearLayout) inflater.inflate( R.layout.example_activity, null );

화면에 그리기

setContentView(linearLayout);

추가

참고 자료

https://aroundck.tistory.com/39

http://developer.android.com/reference/android/view/LayoutInflater.html

댓글남기기