In this paper, a cross-layer framework to perform spectrum sensing and scheduling in agile wireless networks under resource constraints is presented. A network of secondary users (SUs) opportunistically accesses portions of the spectrum left unused by a network of licensed primary users (PUs). A central controller (CC) schedules the traffic of the SUs over the spectrum bands, based on distributed compressed spectrum sensing performed by the SUs. Both sensing and scheduling are controlled based on the current spectrum occupancy belief, with the goal to maximize the SU throughput, under constraints on the PU throughput degradation and the sensing-transmission cost incurred by the SUs. The high optimization complexity is reduced by proposing a partially myopic scheduling strategy, where the total traffic of the SUs is determined optimally via dynamic programming, whereas the allocation of the resulting total traffic across frequency bands is determined via a myopic maximization of the instantaneous trade-off between PU and SU throughputs, which can be solved efficiently using convex optimization tools. Structural results of the partially myopic scheduling strategy are proved. Simulation results demonstrate how the proposed framework allows to balance optimally the cost of acquisition of state information via distributed spectrum sensing and the cost of data transmission incurred by the SUs, while achieving the best trade-off between PU and SU throughput under the resource constraints available.