List of usage examples for android.widget NumberPicker getCurrent
public @NonNull Drawable getCurrent()
From source file:nz.co.wholemeal.christchurchmetro.PlatformActivity.java
/** * Creates a dialog box that allows a user to set an alarm for a * particular eta for an arrival.//w ww . j a va2 s. c om */ private void createAlarmDialog(final Arrival arrival) { AlertDialog.Builder builder; Context context = getApplicationContext(); LayoutInflater inflater = (LayoutInflater) context.getSystemService(LAYOUT_INFLATER_SERVICE); final View layout = inflater.inflate(R.layout.alarm_dialog, null); final NumberPicker numberPicker = (NumberPicker) layout.findViewById(R.id.number_picker); int start = (arrival.eta > 10 ? 10 : arrival.eta - 1); numberPicker.setRange(1, arrival.eta); numberPicker.setCurrent(start); builder = new AlertDialog.Builder(this); builder.setTitle(R.string.set_alarm).setMessage(R.string.alarm_dialog_text).setView(layout) .setPositiveButton(R.string.set, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { int delay = numberPicker.getCurrent(); createNotificationForArrival(arrival, delay); } }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }).show(); }