Sam*_*Sam 40

没有

只要调用的Activity或Window getLayoutInflater()具有可以调用的相同Context,就getSystemService()没有区别.


证明您可以跟踪返回的LayoutInflater getLayoutInflater()LayoutInflater.from() ,你可以看到这只是一个快捷方式getSystemService()从源代码:

public static LayoutInflater from(Context context) {
    LayoutInflater LayoutInflater =
            (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    if (LayoutInflater == null) {
        throw new AssertionError("LayoutInflater not found.");
    }
    return LayoutInflater;
}
Run Code Online (Sandbox Code Playgroud)

  • 其他证据:````getLayoutInflater()== getSystemService(Context.LAYOUT_INFLATER_SERVICE)````返回````true```` (24认同)