如何在 Android 中 clear/delete/remove 我的 RecyclerView?

How to clear/delete/remove my RecyclerView in Android?

当我在我的数据库中搜索用户时,它会填充 RecyclerView,但是当我进行另一次搜索时,它找不到用户,我希望它也删除 RecyclerView 的内容,但是旧用户内容保留在 RecyclerView 中,直到我搜索现有用户,然后它更改为新用户内容。

@OnClick(R.id.btn_search_user)
    public void onSearchBtnClicked(View view) {
        Log.e(LOG_TAG, "Search button clicked");
        if (!TextUtils.isEmpty(etSearchUser.getText())) {
            userNameSearch = etSearchUser.getText().toString();

            if (!isNetworkAvailable()) {
                Toast.makeText(this, "No internet, searching offline", Toast.LENGTH_SHORT).show();
                mOwner = Owner.getByUsername(userNameSearch);
                if(mOwner != null) {
                    searchUserByUserName(userNameSearch);
                } else {
                    // I want the RecyclerView to be empty at this point.
                    tvGitHubUser.setText("was not found offline");
                }
            } else {
                loadRepository(userNameSearch);
                Log.e(LOG_TAG, "Owner is empty, searching online");
            }
        }
    }

initRecycleView()

mGithubRecyclerView = (RecyclerView) findViewById(R.id.github_repository_recyclerview);
        RecyclerView.LayoutManager mGithubLayoutManager = new LinearLayoutManager(getApplicationContext());
        mGithubRecyclerView.setLayoutManager(mGithubLayoutManager);
        mGithubRecyclerView.setHasFixedSize(true);

简单地说,调用recyclerView.setAdapter(null);

如果你能告诉我你的适配器代码,我可以提供更好的方法。