2017-06-12 89 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);