如何使导航抽屉列表项GONE,而不是INVISIBLE

时间:2016-01-08 17:02:06

标签: android navigation-drawer visibility

应用有Navigation Drawer。我试图在抽屉的自定义ArrayList适配器的getView()中将其可见性设置为GONE的View返回,抽屉仍有该项的空白空间。它是看不见的,没有消失。有没有办法让它在不改变列表的情况下消失?

public View getView(int position, View convertView, ViewGroup parent){
        View v = convertView;
        if (v == null) {
            LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = inflater.inflate(iDrawerItemLayoutId, null);
        }
        v.setVisibility(View.GONE);
        return v;
}

1 个答案:

答案 0 :(得分:-1)

您必须更新适配器,然后通过调用其notifydatasetchanged()方法刷新ListView。