You'll need to build a sort of redstone loop system to allow the hopper minecart some time to stop at a hopper and unload then activate a rail beneath it once it's empty to get it to start back up.
Here's a very simple way to do that :)
https://www.youtube.com/shorts/2bp5qeVHd_0