onCreateView method gets called when? and How many times in Activity life cycle?

后端 未结 4 933
甜味超标
甜味超标 2020-12-13 14:06

I wrote a little program looking like this:

package com.example.lifecycle;

import android.app.Activity;
import android.content.Context;
import android.os.Bu         


        
4条回答
  •  时光取名叫无心
    2020-12-13 14:15

    Android Framework uses mechanism of Dependencies injection When layout file is inflated.I think due to this onCreateView is called so many times.Formula for this might be as below

    • no of view in layout xml == no of calls to onCreateView

    Try to remove setContentView and see how many times onCreateView is called.You might get some insights into it.

提交回复
热议问题