Android

Inflate 설명

Dean83 2022. 5. 24. 11:09

1. 설명
    - xml 에 정의된 UI들을 코드에서 쓸 수 있도록 메모리에 올리는 작업

    - 다른 xml의 항목들도 메모리에 올려 사용할 수 있다. 

 

2. 사용

    - 기본적으로 setContentView(R.layout....) 으로 inflate 작업이 수행된다.

    - 대체로 바인딩을 많이 사용할 것이므로, ActivityMainBinding.inflate(layoutInflater) 또는

      DataBindingUtil.setContentView(this,R.layout...) 으로도 할 수 있다. 

 

    혹은 layoutinflater를 이용할 수 있다. 

 var test : LayoutInflater = layoutInflater
 test.inflate(R.layout.fragment_blank,null)