A Simple Example:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<NumberPicker
android:id="@+id/number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
<Button
android:id="@+id/apply_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/number_picker"
android:text="Apply" />
</RelativeLayout>
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.NumberPicker;
public class NumberPickerActivity extends Activity
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.billing_day_dialog);
NumberPicker np = (NumberPicker)findViewById(R.id.number_picker);
np.setMinValue(1);// restricted number to minimum value i.e 1
np.setMaxValue(31);// restricked number to maximum value i.e. 31
np.setWrapSelectorWheel(true);
np.setOnValueChangedListener(new NumberPicker.OnValueChangeListener()
{
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal)
{
// TODO Auto-generated method stub
String Old = "Old Value : ";
String New = "New Value : ";
}
});
Log.d("NumberPicker", "NumberPicker");
}
}/* NumberPickerActivity */
<activity
android:name="org.npn.analytics.call.NumberPickerActivity"
android:theme="@android:style/Theme.Holo.Dialog"
android:label="@string/title_activity_number_picker" >
</activity>
Hope it will help.