android put loading message when load another acitvity
-
Hello everyone, First I'm new here once again hello all. Actually my question is very simple and I'm new in android, How to put loading message (whether text or progress bar) after user click on new activity, I have 2 activity both are: MainActivity and DashboardActivity Here's MainActivity code :
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);findViewById(R.id.textViewTest).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(MainActivity.this, DashboardActivity.class));
}
});
}
}DashboardActivity
public class DashboardActivity extends AppCompatActivity
{
private Toolbar mTopToolbar;
private AppBarConfiguration mAppBarConfiguration;
private NavigationView navigationView;
private int progressStatus = 0;
private Handler handler = new Handler();
private ProgressBar progressBar;@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity\_drawer); // Find the toolbar view inside the activity layout Toolbar toolbar = findViewById(R.id.toolbar); // Sets the Toolbar to act as the ActionBar for this Activity window. // Make sure the toolbar exists in the activity and is not null setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); DrawerLayout drawer = findViewById(R.id.drawer\_layout); navigationView = findViewById(R.id.nav\_view); View hview = navigationView.getHeaderView(0); // Passing each menu ID as a set of Ids because each // menu should be considered as top level destinations. mAppBarConfiguration = new AppBarConfiguration.Builder( R.id.nav\_home, R.id.nav\_gallery, R.id.nav\_slideshow) .setOpenableLayout(drawer) .build(); NavController navController = Navigation.findNavController(this, R.id.nav\_host\_fragment); NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); NavigationUI.setupWithNavController(navigationView, navController); }
-
Hello everyone, First I'm new here once again hello all. Actually my question is very simple and I'm new in android, How to put loading message (whether text or progress bar) after user click on new activity, I have 2 activity both are: MainActivity and DashboardActivity Here's MainActivity code :
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);findViewById(R.id.textViewTest).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
startActivity(new Intent(MainActivity.this, DashboardActivity.class));
}
});
}
}DashboardActivity
public class DashboardActivity extends AppCompatActivity
{
private Toolbar mTopToolbar;
private AppBarConfiguration mAppBarConfiguration;
private NavigationView navigationView;
private int progressStatus = 0;
private Handler handler = new Handler();
private ProgressBar progressBar;@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity\_drawer); // Find the toolbar view inside the activity layout Toolbar toolbar = findViewById(R.id.toolbar); // Sets the Toolbar to act as the ActionBar for this Activity window. // Make sure the toolbar exists in the activity and is not null setSupportActionBar(toolbar); getSupportActionBar().setDisplayShowTitleEnabled(false); DrawerLayout drawer = findViewById(R.id.drawer\_layout); navigationView = findViewById(R.id.nav\_view); View hview = navigationView.getHeaderView(0); // Passing each menu ID as a set of Ids because each // menu should be considered as top level destinations. mAppBarConfiguration = new AppBarConfiguration.Builder( R.id.nav\_home, R.id.nav\_gallery, R.id.nav\_slideshow) .setOpenableLayout(drawer) .build(); NavController navController = Navigation.findNavController(this, R.id.nav\_host\_fragment); NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration); NavigationUI.setupWithNavController(navigationView, navController); }
Are you saying that it takes 4-5 seconds to go from one activity to another within the same app?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
Are you saying that it takes 4-5 seconds to go from one activity to another within the same app?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
-
David Crow wrote:
Are you saying that it takes 4-5 seconds to go from one activity to another within the same app?
Yes, it because I used asynctask and cause frameskipping. But thanks for reply
GongTji wrote:
...because I used asynctask...
Which is not shown in the code you provided.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles