我可以知道
public View getView(int position, View view, ViewGroup parent){
if (view ==null)
view = getLayoutInflater().inflate(R.layout.listview_item, parent, false);
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以向我解释谢谢!
LayoutInflater有两个相关的重载inflate:
public View inflate (int resource, ViewGroup root, boolean attachToRoot)
public View inflate (int resource, ViewGroup root)
Run Code Online (Sandbox Code Playgroud)
第二个参数是要引用为要放大的视图的根的视图。如果attachToRoot为true,它将成为展开视图的父视图。如果没有,它只会帮助创建正确的布局。
如果使用第二个重载,则假定attachToRoot为true,并且如果提供(可选)根,它将作为父视图自动附加到膨胀视图。
| 归档时间: |
|
| 查看次数: |
6656 次 |
| 最近记录: |