简体   繁体   English

Android ListView setVisibility不起作用

[英]Android ListView setVisibility not working

I have a ListView in my RelativeLayout that is supposed to be hidden during a search is executed. 我的RelativeLayout中有一个ListView,应该在执行搜索期间将其隐藏。 Therefore I implemented the following code: 因此,我实现了以下代码:

mProgressView.setVisibility(View.VISIBLE);
mSearchListView.setVisibility(View.INVISIBLE);
mSearchAdapter.search(query).onSuccess(new Continuation<Set<Integer>, Object>() {
    @Override
    public Object then(final Task<Set<Integer>> task) throws Exception {
        runOnUiThread(new Runnable() {
            @Override
            public void run() 
                mSearchAdapter.notifyDataSetChanged();

                mProgressView.setVisibility(View.INVISIBLE);
                mSearchListView.setVisibility(View.VISIBLE);
            }
        });
        return null;
    }
});

Unfortunately, the ListView stays visible. 不幸的是,ListView保持可见。 The ProgressView start to spin successfully but the list view remains visible. ProgressView开始成功旋转,但是列表视图仍然可见。 Any hints on what to do? 关于做什么的任何提示?

When you say it stays 'visible' do you mean you see data in the listview or just that some space seems to be occupied by an invisible listview? 当您说它保持“可见”时,您是说您在列表视图中看到了数据,还是只是隐性列表视图似乎占据了一些空间?

If the latter is the case then you should try making the listview GONE as - 如果是后者,则应尝试使listview变为-

mSearchListView.setVisibility(View.GONE);

instead of making it invisible 而不是使其不可见

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM