Why did sir create the custom adapter class inside the main activity class?

No specific reason as such, you can feel free to create a new class for it!