Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/193.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 替换碎片的速度非常慢_Android_Fragmentmanager - Fatal编程技术网

Android 替换碎片的速度非常慢

Android 替换碎片的速度非常慢,android,fragmentmanager,Android,Fragmentmanager,我发现替换碎片时速度非常慢 是否有任何事件获取提交状态,我想知道它是finish commit 这是我的密码。。我想在processbar更改时禁用它 @Override public void onDrawerClosed(@NonNull View drawerView) { if (mFragmentToSet != null) { ((ProgressBar)findViewById(R.id.progressBar)).setVisibility(View.V

我发现替换碎片时速度非常慢

是否有任何事件获取提交状态,我想知道它是finish commit

这是我的密码。。我想在processbar更改时禁用它

@Override
public void onDrawerClosed(@NonNull View drawerView) {

    if (mFragmentToSet != null) {
        ((ProgressBar)findViewById(R.id.progressBar)).setVisibility(View.VISIBLE);
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.flContent, mFragmentToSet).commit();
((ProgressBar)findViewById(R.id.progressBar)).setVisibility(View.GONE);
        mFragmentToSet = null;}

我从来没有觉得替换片段很慢,这可能是因为您在onCreateView或OnCreateofFragment的UI线程中做了很多事情。你能添加加载缓慢的片段吗?在我的情况下…在抽屉关闭后。。片段仍然需要1-2秒才能关闭并替换新片段为什么要在onDrawerClosed上设置片段?为什么不为此使用onNavigationDrawerItemSelected回调?如果需要在单击抽屉项目时更改片段,可以在NavigationDrawerItemSelected上使用此方法。如果您需要解释,请告诉我我会发布一个答案。这是因为如果我在onNavigationDrawerItemSelected上替换。。它会冻结直到碎片变了..我找到了答案。。。在创建其他视图时设置可见性。