I have a numberpicker:
AlertDialog alertDialog = builder.create();
NumberPicker NP = (NumberPicker)view.findViewById(R.id.npicker);
As per the documentation,
NumberPicker (and all its methods) are available only from API Level 11 (SDK 3.0). So if you want compatibility with 2.3.x, you need to have your own implementation. Luckily there is one already available here
The Internet has been not so gentle on the link above and it is no longer available. Even the alternatives suggested in the comments are also gone. You are better off writing your own.