我们有HomeActivity,它是NavigationDrawyer活动,其中有很多选项,例如职位和政策。如果他是第一次点击职位, 我们将显示JobUserForm.class,然后从下一次开始,如果他单击JobsList,然后单击JobDetails,则将显示JobsList.class。策略也采用相同的方法。问题是当我在这些页面之间导航时,上一页在后台闪烁几秒钟。例如,如果我在加载作业时单击homeActivity中的作业,则列表屏幕homeActivity屏幕在background.in中闪烁加载jobDetails屏幕作业时的方法与之相同。政策也是如此。我该如何解决。请提供解决方案。
在我的HomeActiivty.class中
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem menuItem) {
menuItem.setChecked(true);
// close drawer when item is tapped
switch (menuItem.getItemId()) {
case R.id.nav_item_jobs:
if (internetConnection.checkConnection()) {
govJobs();
} else {
Toast.makeText(HomeActivity.this, "No internet connection", Toast.LENGTH_LONG).show();
}
break;
case R.id.nav_item_policies:
if (internetConnection.checkConnection()) {
govPolicies();
} else {
Toast.makeText(HomeActivity.this, "No internet connection", Toast.LENGTH_LONG).show();
}
break;
case R.id.nav_item_my_servant:
Toast.makeText(HomeActivity.this, "Coming soon", Toast.LENGTH_LONG).show();
break;
}
drawer.closeDrawers();
return true;
}
private void govJobs() {
job_rows_count = myAppDataBase.myDao().getNumberOfJobRows();
if (job_rows_count >= 1) {
// getWindow().setExitTransition(null);
Intent intent = new Intent(HomeActivity.this, JobsList.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
//
Intent intent =new Intent(HomeActivity.this, JobUserForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
private void govPolicies() {
policy_row_count = myAppDataBase.myDao().getNumberOfPolicyRows();
if (policy_row_count >= 1) {
Intent intent = new Intent(HomeActivity.this, PoliciesGrid.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
Intent intent = new Intent(HomeActivity.this, PolicyUserForm.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
答案 0 :(得分:0)
您需要在startactivity()之后使用overridePendingTransition(0,0);
来删除切换活动时要使用的所有转换。