0

I am trying to make an app in which I want the menu items in the navigation drawer to open/work one-by-one automatically. Each of these items is coded in onNavigationItemSelected using switch-case. When a menu item is tapped, it triggers a code which setImageResource to desirable images.

Now, I want to make it more like a slideshow were each of the items are clicked and images related to them are shown on the screen. I am using the code below

for (int i = 0; i <50; i++){
    final int finalI = i;
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {                                
            navigationView.getMenu().getItem(finalI).setChecked(true);
        }
      }, 4000);
}

I am new to android and programming in general and I don't know how to attain the functionalities I want. If there is something that we can change in the code above or if there is anything that could help in attaining the goal, please do tell me and help me with it.

1 Answers1

0

I saw this solution that may help you where you can put your for loop in the onCreate(): [onClick event in navigation drawer

The answer where it starts with "you need to add implements NavigationView.OnNavigationItemSelectedListener"

It has code for Implements NavigationView.OnNavigationItemSelectedListener, then Add method, then set Listener, and call method in onCreate()

Kenny
  • 11
  • 3