About 300 Prince George's County schoolchildren were detained at District Heights Elementary School and Francis Scott Key Middle School for up 90 minutes yesterday afternoon after residents in a nearby District Heights apartment building reported a gunman hiding in their building.

The witnesses said the man had shot a gun at a moving automobile, according to Prince George's County police. Nearly 40 police officers, members of the Emergency Services Team and Special Operations Division, and area patrol officers cordoned off a two-block area in the 6500 block of Atwood Street near Rochelle Avenue shortly after noon.

Police conducted a door-to-door search of apartments and took two men into custody about 3:30 p.m., according to Cpl. Bruce D. Gentile, a police spokesman. No weapon was found and no charges have been filed, police said.

Witnesses told police that a man with a gun fired at the occupant of a moving gray car, shattering the rear window. The car's driver sped off and was not believed to have been wounded, the witnesses said. Police said they were unable to locate the driver yesterday.

The alleged gunman ran into the building. Police blocked off the area and notified officials at the two nearby schools. About 200 youngsters who walk to the elementary school, about four blocks from the scene, were not released at 2 p.m. as usual, because school officials and police did not want them walking near the barricade. About 100 students who live in the area but ride buses to magnet schools were taken to the elementary school. Students at nearby Francis Scott Key Middle School scheduled to be out at 3 p.m. also were detained.