2017-06-12 127 views
-3

我试图夸大布局,我碰到这两个code.Can人请告诉我这两种膨胀方法之间的区别? 我是新来的android工作室,我想了解更多关于这种膨胀方法。 除了这两个有没有其他的方式来扩大布局?不同的方式膨胀布局

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; 
} 

回答

0

为了得到的图(如果需要在OnCreate中getLayoutInflater的内部片段使用()取代oncreateview充气物体)

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

为了得到用于列表视图的图

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