不同的方式膨胀布局

Different ways inflate a layout

我正在尝试对布局进行膨胀,但遇到了这两个 code.Can 有人请告诉我这两种膨胀方法之间的区别吗? 我是 android studio 的新手,我想了解更多关于这个 inflate 方法的信息。 另外除了这两个还有其他方法来膨胀布局吗?

public MyViewHolder onCreateViewHolder(ViewGroup parent,int viewType){
    View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.movie_list_row, parent, false);
    return new MyViewHolder(itemView);
}

LayoutInflater inflater = LayoutInflater.from(context);
    View rowView = inflater.inflate(R.layout.list_single, null, true);
    return rowView;
}

用于获取视图(如果需要在片段中使用 oncreate getLayoutInflater() 替换 oncreateview inflater 对象)

 View v=getLayoutInflater().inflate(R.layout.activity_main2,null);

获取列表视图的视图

View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_row,parent,false);