MenuInflater是用来加载menu布局文件的。

与LayoutInflater类似,应用程序运行时会预先加载资源中的布局文件,如果Menu布局中的资源比较多,会影响性能,所以可以选择MenuInflater方式用的时候加载,这样减轻了应用程序运行时很多负担

与LayoutInflater相比,MenuInflater用法要简单很多,它只有Activity.getMenuInflater()方法和MenuInflater(Context context)方法。

然后调用MenuInflater的方法inflate(int menuRes, Menu menu)方法加载布局。

相关文章:

  • 2021-04-09
  • 2021-12-28
  • 2022-03-10
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
猜你喜欢
  • 2021-09-05
  • 2021-08-01
  • 2022-01-04
  • 2021-05-20
相关资源
相似解决方案