I have an ATmega8 with a Nokia LCD 5510 connected to it. Everything works great on a breadboard and my next step is to move it to a more permanent board. My problem is that I can't program the ATmega8 while the LCD is also connected. I assume it's because they use the same SPI pins and that the LCD somehow interferes with the programming. How can I do this different so that I can flash the ATmega via ISP without unplugging the LCD?
You have to prevent any other device from driving the SPI lines during programming.
To avoid driver contention, a series resistor should be placed on each of the three dedicated lines if there is a possibility that external circuitry could be driving these lines.
Take a look at Application note AVR910.
To avoid problems, the In-System Programmer should be able to keep the entire Target System Reset for the duration of the programming cycle. The target system should never attempt to drive the three SPI lines while Reset is active.
So it would be best if the reset lines of the ATMEGA and the display are functionally connected to prevent the display from doing anything while the programmer holds reset.
Another solution is to disable the screen during programming.
The screen is active when the CS (chip select) pin is low (0v). If you put a 10kR pull-up resistor between the CS pin and 3V3, it will be disabled/high by default. To enable it, connect the CS pin to an output of you micro controller and set that output to low (0V). I did that on one of my projects and it works well.
The screen runs at 3.3V, you will have to add voltage divider if your micro controller runs at 5V.