它的介绍说是可以生成ViewHolder和findView方法的代码。不过怎么生成findView方法的代码我还没找到,但生成ViewHolder也是挺酷炫的。

在你的Adapter实现类的getView当中,将光标定位到你的布局文件的ID的变量中,按Alt+Insert插件代码,可以看到多了一项Create view holder,如下图。

选择它之后,它会根据布局文件里的声明了id的元素,为你生成对应的ViewHolder代码,如下所示:

public class ViewHolder {  
    public final TextView time;  
    public final ImageView isnew;  
    public final TextView username;  
    public final TextView department;  
    public final ImageView enter;  
    public final CircleImageView avatar;  
    public final RelativeLayout listcontent;  
    public final View root;  

    public ViewHolder(View root) {  
        time = (TextView) root.findViewById(R.id.time);  
        isnew = (ImageView) root.findViewById(R.id.is_new);  
        username = (TextView) root.findViewById(R.id.username);  
        department = (TextView) root.findViewById(R.id.department);  
        enter = (ImageView) root.findViewById(R.id.enter);  
        avatar = (CircleImageView) root.findViewById(R.id.avatar);  
        listcontent = (RelativeLayout) root.findViewById(R.id.list_content);  
        this.root = root;  
    }  
}

很方便吧?

results matching ""

    No results matching ""