In this paper, a scheme for specifying contact angle and its hysteresis is incorporated into a multiphase lattice Boltzmann method. The scheme is validated through investigations of the dynamic behaviors of a droplet sliding along two kinds of walls: a smooth (ideal) wall and a rough or chemically inhomogeneous (nonideal) wall. For an ideal wall, the wettability of solid substrates is able to be prescribed. For a nonideal wall, arbitrary contact angle hysteresis can be obtained through adjusting advancing and receding angles. Significantly different phenomena can be recovered for the two kinds of walls. For instance, a droplet on an inclined ideal wall under gravity is impossible to stay stationary. However, the droplet on a nonideal wall may be pinned due to contact angle hysteresis. The steady interface shapes of the droplet on an inclined nonideal wall under gravity or in a shear flow quantitatively agree well with the previous numerical studies. Besides, the complex motion of a droplet creeping like an inchworm could be simulated. The scheme is found suitable for the study of contact line problems with and without contact angle hysteresis.