java - Android Studio。 Activity 更改后的屏幕轻弹

标签 java android android-studio

在更改导航标题中的活动之后,我出现了奇怪的闪烁,并且希望摆脱它们:

enter image description here

我不确定我应该显示代码的哪一部分,但是我猜想问题可能出在意图的创建方式或类似方面。这是我的导航按钮的代码:

@Override
public boolean onNavigationItemSelected(MenuItem item) {
    // Handle navigation view item clicks here.
    int id = item.getItemId();

    if (id == R.id.main) {
        Intent main = new Intent(main.this, main.class);
        main.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(main);
    } else if (id == R.id.find_friends) {
        Intent findfriends = new Intent(main.this, FindFriends.class);
        findfriends.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(findfriends);
    } else if (id == R.id.followers) {
        Intent followers = new Intent(main.this, Followers.class);
        followers.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(followers);
    } else if (id == R.id.follow) {
        Intent follow = new Intent(main.this, Follow.class);
        follow.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(follow);
    } else if (id == R.id.statistics) {
        Intent statistic = new Intent(main.this, statistic.class);
        statistic.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(statistic);
    } else if (id == R.id.LogOut) {
        FirebaseAuth.getInstance().signOut();
        Intent mainact = new Intent(main.this, MainActivity.class);
        mainact.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(mainact);
    } else if (id == R.id.About) {
        Intent about = new Intent(main.this, About.class);
        about.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(about);
    }

    DrawerLayout drawer = findViewById(R.id.drawer_layout);
    drawer.closeDrawer(GravityCompat.START);
    return true;
}

最佳答案

这可能与.Set方法有关。尝试删除about.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)GravityCompact.Start可能是您的问题,但这不太可能。老实说,我认为这只是一个小故障。尝试更新您的Android Studio或正在使用的设备将是很好的选择。如果那不起作用,请尝试this它仅适用于Jelly Bean,但您可以更改代码来满足您的要求。祝你好运!

关于java - Android Studio。 Activity 更改后的屏幕轻弹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58963471/

相关文章:

java - 使用未知人士的外部库有哪些风险?可能是恶意软件吗?

android - 如何在 Activity 之间传递游戏中心数据?

android - 在包 '...' 中找不到属性 'com.app....' 的资源标识符

java调用方法不输出任何内容

java - 使用反射时处理或转换从 method.invoke() 返回的对象

Java(安卓): How to I split a string by every two line breaks?

java - Android 提示的颜色代码是什么?

android - 仅在手机上显示通知(不在 Android Wear 上)

android - 如何避免每次运行 Espresso 时出现 'Gradle build'

android - 导航组件,没有设置 NavController,在 androidx.navigation.Navigation.findNavController 没有设置 NavController