2012-12-24 27 views
5

這兩者有什麼區別嗎?使用上下文獲取LayoutInflater

  1. inflater = (LayoutInflater) LayoutInflater.from(context);
  2. inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

回答

4

不是在現在,你可以通過檢查the LayoutInflater source code看到。 from()將拋出一個Exception而不是返回null,但否則它們是相同的。

我個人最多使用getLayoutInflater()