在更改导航标题中的活动之后,我出现了奇怪的闪烁,并且希望摆脱它们:
我不确定我应该显示代码的哪一部分,但是我猜想问题可能出在意图的创建方式或类似方面。这是我的导航按钮的代码:
@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/