android 之隐藏一批view

在编写框架和定义BaseActivity时,可以添加此方法。

    /**
     * 显示一批View
     * @param views
     */
    public void showView(View... views){
        for (int i = 0; i < views.length; i++) {
            View view = views[i];
            if(view != null){
                view.setVisibility(View.VISIBLE);
            }
        }
    }
    /**
     * 隐藏一批View
     * @param views
     */
    public void hideView(View... views){
        for (int i = 0; i < views.length; i++) {
            View view = views[i];
            if(view != null){
                view.setVisibility(View.GONE);
            }
        }
    }

你可能感兴趣的:(工具类)