Example usage for android.app DatePickerDialog DatePickerDialog

List of usage examples for android.app DatePickerDialog DatePickerDialog

Introduction

In this page you can find the example usage for android.app DatePickerDialog DatePickerDialog.

Prototype

public DatePickerDialog(@NonNull Context context, @Nullable OnDateSetListener listener, int year, int month,
        int dayOfMonth) 

Source Link

Document

Creates a new date picker dialog for the specified date using the parent context's default date picker dialog theme.

Usage

From source file:com.abeo.tia.noordin.ProcesscaseLoanSubsidiary.java

@Override
public void onClick(View v) {
    if (v == details_btn) {
        Intent to_purchaser = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCaseDetails.class);
        startActivity(to_purchaser);/*w ww  .  j a  va2 s. c om*/
    }
    if (v == purchaser_btn) {
        Intent to_purchaser = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCasePurchaser.class);
        startActivity(to_purchaser);
    }
    if (v == vendor_btn) {
        Intent to_vendor = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCaseVendor.class);
        startActivity(to_vendor);
    }
    if (v == property_btn) {
        Intent to_loan_pricipal = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCaseProperty.class);
        startActivity(to_loan_pricipal);
    }
    if (v == loan_principal_btn) {
        Intent to_loan_pricipal = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCaseLoanPrincipal.class);
        startActivity(to_loan_pricipal);
    }
    if (v == loan_subsidary_btn) {
        Intent to_loan_subsidiary = new Intent(ProcesscaseLoanSubsidiary.this, ProcesscaseLoanSubsidiary.class);
        startActivity(to_loan_subsidiary);
    }
    if (v == process_btn) {
        Intent to_loan_subsidiary = new Intent(ProcesscaseLoanSubsidiary.this, ProcessCaseProcessTab.class);
        startActivity(to_loan_subsidiary);
    }

    EeditText_dischargeofcharge.setOnClickListener(this);
    if (v == ELoanDocForBankExe) {
        new DatePickerDialog(ProcesscaseLoanSubsidiary.this, ELoanDocForBankExe1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (v == EFaciAgreeDate) {
        new DatePickerDialog(ProcesscaseLoanSubsidiary.this, EFaciAgreeDate1, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (v == EeditText_loan_doc_bank) {
        new DatePickerDialog(ProcesscaseLoanSubsidiary.this, EeditText_loan_doc_bank1,
                myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (v == EeditText_dischargeofcharge) {
        new DatePickerDialog(ProcesscaseLoanSubsidiary.this, EeditText_dischargeofcharge1,
                myCalendar.get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
                myCalendar.get(Calendar.DAY_OF_MONTH)).show();
    }
    if (v == walkin) {
        Intent i = new Intent(ProcesscaseLoanSubsidiary.this, WalkInActivity.class);
        startActivity(i);
    }
    if (v == confirm_allvalues_btn) {
        try {
            confirm_allvalues();
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

From source file:cl.gisred.android.InspActivity.java

public void setActionsForm(final int idRes, String sNombre) {
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(idRes, null);

    final int topeWidth = 650;
    ArrayAdapter<CharSequence> adapter;

    DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    int widthSize = displayMetrics.widthPixels;
    int widthScale = (widthSize * 3) / 4;
    if (topeWidth < widthScale)
        widthScale = topeWidth;/*from w ww  .j  av  a 2 s. com*/

    v.setMinimumWidth(widthScale);

    formCrear.setTitle(sNombre);
    formCrear.setContentView(v);
    idResLayoutSelect = idRes;

    boolean bSpinnerMedidor = idRes == R.layout.form_inspec_telemedida;

    Spinner spTipoFase = (Spinner) v.findViewById(R.id.spinnerFase);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            arrayTipoFaseInsp);
    spTipoFase.setAdapter(adapter);

    Spinner spTipoMarca = (Spinner) v.findViewById(R.id.spinnerTipo);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            (bSpinnerMedidor) ? arrayTipoMarcaTM : arrayTipoMarca);
    spTipoMarca.setAdapter(adapter);

    Spinner spMarca = (Spinner) v.findViewById(R.id.spinnerMarca);
    adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
            (bSpinnerMedidor) ? arrayMarcaTM : arrayMarca);
    spMarca.setAdapter(adapter);

    final GisEditText txtPoste = (GisEditText) v.findViewById(R.id.txtPoste);
    final EditText txtRotulo = (EditText) v.findViewById(R.id.txtRotulo);

    txtPoste.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        }

        @Override
        public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            if (i2 > 1) {
                if (bInspRotulo) {
                    txtRotulo.setText(charSequence);
                    if (!txtRotulo.hasFocus())
                        txtRotulo.requestFocus();
                    bInspRotulo = false;
                    txtPoste.setText(String.format("%s", txtPoste.getIdObjeto()));
                } else
                    bInspRotulo = true;
            }
        }

        @Override
        public void afterTextChanged(Editable editable) {
        }
    });

    ImageButton btnIdentPoste = (ImageButton) v.findViewById(R.id.btnPoste);
    btnIdentPoste.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            formCrear.hide();
            bMapTap = true;
            bCallOut = true;
            oLySelectAsoc = LyAddPoste;
            oLyExistAsoc = LyPOSTES;
            oLyExistAsoc.setVisible(true);
            myMapView.zoomToScale(ldm.getPoint(), oLyExistAsoc.getMinScale() * 0.9);
            setValueToAsoc(getLayoutContenedor(view));
        }
    });

    final EditText txtFecha = (EditText) v.findViewById(R.id.txtFechaEjec);
    txtFecha.setText(dateFormatter.format(Calendar.getInstance().getTime()));
    txtFecha.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            datePickerDialog.show();
        }
    });

    Calendar newCalendar = Calendar.getInstance();
    datePickerDialog = new DatePickerDialog(this, new DatePickerDialog.OnDateSetListener() {

        public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
            Calendar newDate = Calendar.getInstance();
            newDate.set(year, monthOfYear, dayOfMonth);
            txtFecha.setText(dateFormatter.format(newDate.getTime()));
        }

    }, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));

    final EditText txtHoraIni = (EditText) v.findViewById(R.id.txtHoraIni);
    txtHoraIni.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            timePickerDialog.show();
            txtHora = txtHoraIni;
        }
    });

    final EditText txtHoraFin = (EditText) v.findViewById(R.id.txtHoraFin);
    txtHoraFin.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            timePickerDialog.show();
            txtHora = txtHoraFin;
        }
    });

    timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) {
            txtHora.setText(String.format(Locale.getDefault(), "%02d:%02d", selectedHour, selectedMinute));
        }
    }, newCalendar.get(Calendar.HOUR), newCalendar.get(Calendar.MINUTE), false);

    final EditText txtEjecutor = (EditText) v.findViewById(R.id.txtEjecutor);
    txtEjecutor.setText(Util.getUserWithoutDomain(usuar));

    Spinner spFirmante = (Spinner) v.findViewById(R.id.spinnerFirmante);
    if (spFirmante != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayFirmante);
        spFirmante.setAdapter(adapter);
        spFirmante.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
                setRequerido(view, R.id.txtRutInst, i > 0);
                setRequerido(view, R.id.txtNomInst, i > 0);
            }

            @Override
            public void onNothingSelected(AdapterView<?> adapterView) {
            }
        });
    }

    Spinner spTipoMarcaRet = (Spinner) v.findViewById(R.id.spinnerTipoRet);
    if (spTipoMarcaRet != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayTipoMarca);
        spTipoMarcaRet.setAdapter(adapter);
    }

    Spinner spMarcaRet = (Spinner) v.findViewById(R.id.spinnerMarcaRet);
    if (spMarcaRet != null) {
        adapter = new ArrayAdapter<CharSequence>(this, R.layout.support_simple_spinner_dropdown_item,
                arrayMarca);
        spMarcaRet.setAdapter(adapter);
    }

    final CheckBox chkInspFallo = (CheckBox) v.findViewById(R.id.chkInspFallo);
    if (chkInspFallo != null) {
        chkInspFallo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                bFallo = chkInspFallo.isChecked();
                modoFallo(v, bFallo);
            }
        });
    }

    ImageButton btnClose = (ImageButton) v.findViewById(R.id.btnCancelar);
    btnClose.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(false, v, 0);
        }
    });

    ImageButton btnOk = (ImageButton) v.findViewById(R.id.btnConfirmar);
    btnOk.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            cerrarFormCrear(true, v, idRes);
        }
    });

    imgFirmaTec = (ImageView) v.findViewById(R.id.imgFirmaTec);
    imgFirmaInsp = (ImageView) v.findViewById(R.id.imgFirmaIns);
    imgPhoto1 = (ImageView) v.findViewById(R.id.imgPhoto1);
    imgPhoto2 = (ImageView) v.findViewById(R.id.imgPhoto2);
    imgPhoto3 = (ImageView) v.findViewById(R.id.imgPhoto3);

    final ImageButton btnFirmaTec = (ImageButton) v.findViewById(R.id.btnFirmaTec);
    if (btnFirmaTec != null && imgFirmaTec != null) {
        btnFirmaTec.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                imgTemp = imgFirmaTec;
                DialogoFirma oDialog = new DialogoFirma();
                oDialog.show(getFragmentManager(), "tagFirma");
            }
        });

        imgFirmaTec.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                crearDialogoImg((ImageView) v).show();
                return false;
            }
        });
    }

    final ImageButton btnFirmaInsp = (ImageButton) v.findViewById(R.id.btnFirmaIns);
    if (btnFirmaInsp != null && imgFirmaInsp != null) {
        btnFirmaInsp.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                imgTemp = imgFirmaInsp;
                DialogoFirma oDialog = new DialogoFirma();
                oDialog.show(getFragmentManager(), "tagFirma");
            }
        });

        imgFirmaInsp.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
                crearDialogoImg((ImageView) v).show();
                return false;
            }
        });
    }

    imgPhoto1.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    imgPhoto2.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    imgPhoto3.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            crearDialogoImg((ImageView) v).show();
            return false;
        }
    });

    ImageButton btnPhoto1 = (ImageButton) v.findViewById(R.id.btnPhoto1);
    btnPhoto1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto1;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto1");
            else
                tomarFoto("foto1");

        }
    });

    ImageButton btnPhoto2 = (ImageButton) v.findViewById(R.id.btnPhoto2);
    btnPhoto2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto2;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto2");
            else
                tomarFoto("foto2");
        }
    });

    ImageButton btnPhoto3 = (ImageButton) v.findViewById(R.id.btnPhoto3);
    btnPhoto3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto3;
            if (Build.VERSION.SDK_INT >= 22)
                verifCamara("foto3");
            else
                tomarFoto("foto3");
        }
    });

    ImageButton btnFile1 = (ImageButton) v.findViewById(R.id.btnFile1);
    btnFile1.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto1;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto1");
            else
                imageGallery("foto1");
        }
    });

    ImageButton btnFile2 = (ImageButton) v.findViewById(R.id.btnFile2);
    btnFile2.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto2;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto2");
            else
                imageGallery("foto2");
        }
    });

    ImageButton btnFile3 = (ImageButton) v.findViewById(R.id.btnFile3);
    btnFile3.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            imgTemp = imgPhoto3;
            if (Build.VERSION.SDK_INT >= 22)
                verifAccesoExterno("foto3");
            else
                imageGallery("foto3");
        }
    });

    arrayTouchs = new ArrayList<>();
    //setEnabledDialog(false);

    formCrear.show();
    dialogCur = formCrear;
}

From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java

private void launchNativeUI(final String jsonData) {
    String id = null;//www  .  j  a v a  2 s  . com
    String uiName = null;
    String result = null;
    try {
        JSONObject json = new JSONObject(jsonData);
        id = json.optString("id");
        uiName = json.optString("uiName");
    } catch (Exception e) {
        DebugLog.d(TAG, "exception = " + e.getMessage());
        result = "{" + "\"code\": \"" + Constants.RESPONSE_500
                + "\",\"message\": \" player internal error(500) \"}";
    }

    if ("datepicker".equals(uiName)) {
        final Calendar myCalendar = Calendar.getInstance();
        DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() {
            @Override
            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                myCalendar.set(Calendar.YEAR, year);
                myCalendar.set(Calendar.MONTH, monthOfYear);
                myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);
                String myFormat = "dd-MM-yyyy"; //In which you need put here
                SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
                String date = sdf.format(myCalendar.getTime());
                String result = "{\"id\": \"" + System.currentTimeMillis()
                        + "\", \"type\":\"set\", \"uiName\" : \"datepicker\", \"data\" : \"" + date + "\" }";
                ubiGCPlayerCallback("returnNativeUI", result);
            }
        };
        new DatePickerDialog(mContext, dateSetListener, myCalendar.get(Calendar.YEAR),
                myCalendar.get(Calendar.MONTH), myCalendar.get(Calendar.DAY_OF_MONTH)).show();

        result = "{" + "\"id\": \"" + id + "\"," + "\"type\": \"result\"," + "\"code\": \"200\","
                + "\"message\": \"success(200)\"" + "}";
    } else {
        result = "{" + "\"code\": \"" + Constants.RESPONSE_500
                + "\",\"message\": \" player internal error(500) \"}";
    }
    ubiGCPlayerCallback("launchNativeUI", result);
}

From source file:com.codename1.impl.android.AndroidImplementation.java

@Override
public Object showNativePicker(final int type, final Component source, final Object currentValue,
        final Object data) {
    if (getActivity() == null) {
        return null;
    }// w w w.  j  a v  a  2 s .  c  o m
    final boolean[] canceled = new boolean[1];
    final boolean[] dismissed = new boolean[1];

    if (editInProgress()) {
        stopEditing(true);
    }
    if (type == Display.PICKER_TYPE_TIME) {

        class TimePick
                implements TimePickerDialog.OnTimeSetListener, TimePickerDialog.OnCancelListener, Runnable {
            int result = ((Integer) currentValue).intValue();

            public void onTimeSet(TimePicker tp, int hour, int minute) {
                result = hour * 60 + minute;
                dismissed[0] = true;
                synchronized (this) {
                    notify();
                }
            }

            public void run() {
                while (!dismissed[0]) {
                    synchronized (this) {
                        try {
                            wait(50);
                        } catch (InterruptedException er) {
                        }
                    }
                }
            }

            @Override
            public void onCancel(DialogInterface di) {
                dismissed[0] = true;
                canceled[0] = true;
                synchronized (this) {
                    notify();
                }
            }
        }
        final TimePick pickInstance = new TimePick();
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                int hour = ((Integer) currentValue).intValue() / 60;
                int minute = ((Integer) currentValue).intValue() % 60;
                TimePickerDialog tp = new TimePickerDialog(getActivity(), pickInstance, hour, minute, true) {

                    @Override
                    public void cancel() {
                        super.cancel();
                        dismissed[0] = true;
                        canceled[0] = true;
                    }

                    @Override
                    public void dismiss() {
                        super.dismiss();
                        dismissed[0] = true;
                    }

                };
                tp.setOnCancelListener(pickInstance);
                //DateFormat.is24HourFormat(activity));
                tp.show();
            }
        });
        Display.getInstance().invokeAndBlock(pickInstance);
        if (canceled[0]) {
            return null;
        }
        return new Integer(pickInstance.result);
    }
    if (type == Display.PICKER_TYPE_DATE) {
        final java.util.Calendar cl = java.util.Calendar.getInstance();
        if (currentValue != null) {
            cl.setTime((Date) currentValue);
        }
        class DatePick
                implements DatePickerDialog.OnDateSetListener, DatePickerDialog.OnCancelListener, Runnable {
            Date result = (Date) currentValue;

            public void onDateSet(DatePicker dp, int year, int month, int day) {
                java.util.Calendar c = java.util.Calendar.getInstance();
                c.set(java.util.Calendar.YEAR, year);
                c.set(java.util.Calendar.MONTH, month);
                c.set(java.util.Calendar.DAY_OF_MONTH, day);
                result = c.getTime();
                dismissed[0] = true;
                synchronized (this) {
                    notify();
                }
            }

            public void run() {
                while (!dismissed[0]) {
                    synchronized (this) {
                        try {
                            wait(50);
                        } catch (InterruptedException er) {
                        }
                    }
                }
            }

            public void onCancel(DialogInterface di) {
                result = null;
                dismissed[0] = true;
                canceled[0] = true;
                synchronized (this) {
                    notify();
                }
            }
        }
        final DatePick pickInstance = new DatePick();
        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                DatePickerDialog tp = new DatePickerDialog(getActivity(), pickInstance,
                        cl.get(java.util.Calendar.YEAR), cl.get(java.util.Calendar.MONTH),
                        cl.get(java.util.Calendar.DAY_OF_MONTH)) {

                    @Override
                    public void cancel() {
                        super.cancel();
                        dismissed[0] = true;
                        canceled[0] = true;
                    }

                    @Override
                    public void dismiss() {
                        super.dismiss();
                        dismissed[0] = true;
                    }

                };
                tp.setOnCancelListener(pickInstance);
                tp.show();
            }
        });
        Display.getInstance().invokeAndBlock(pickInstance);
        return pickInstance.result;
    }
    if (type == Display.PICKER_TYPE_STRINGS) {
        final String[] values = (String[]) data;
        class StringPick implements Runnable, NumberPicker.OnValueChangeListener {
            int result = -1;

            StringPick() {
            }

            public void run() {
                while (!dismissed[0]) {
                    synchronized (this) {
                        try {
                            wait(50);
                        } catch (InterruptedException er) {
                        }
                    }
                }
            }

            public void cancel() {
                dismissed[0] = true;
                canceled[0] = true;
                synchronized (this) {
                    notify();
                }
            }

            public void ok() {
                canceled[0] = false;
                dismissed[0] = true;
                synchronized (this) {
                    notify();
                }
            }

            @Override
            public void onValueChange(NumberPicker np, int oldVal, int newVal) {
                result = newVal;
            }
        }

        final StringPick pickInstance = new StringPick();
        for (int iter = 0; iter < values.length; iter++) {
            if (values[iter].equals(currentValue)) {
                pickInstance.result = iter;
                break;
            }
        }
        if (pickInstance.result == -1 && values.length > 0) {
            // The picker will default to showing the first element anyways
            // If we don't set the result to 0, then the user has to first
            // scroll to a different number, then back to the first option
            // to pick the first option.
            pickInstance.result = 0;
        }

        getActivity().runOnUiThread(new Runnable() {
            public void run() {
                NumberPicker picker = new NumberPicker(getActivity());
                if (source.getClientProperty("showKeyboard") == null) {
                    picker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
                }
                picker.setMinValue(0);
                picker.setMaxValue(values.length - 1);
                picker.setDisplayedValues(values);
                picker.setOnValueChangedListener(pickInstance);
                if (pickInstance.result > -1) {
                    picker.setValue(pickInstance.result);
                }
                RelativeLayout linearLayout = new RelativeLayout(getActivity());
                RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(50, 50);
                RelativeLayout.LayoutParams numPicerParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
                numPicerParams.addRule(RelativeLayout.CENTER_HORIZONTAL);

                linearLayout.setLayoutParams(params);
                linearLayout.addView(picker, numPicerParams);

                AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
                alertDialogBuilder.setView(linearLayout);
                alertDialogBuilder.setCancelable(false)
                        .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                pickInstance.ok();
                            }
                        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                                pickInstance.cancel();
                            }
                        });
                AlertDialog alertDialog = alertDialogBuilder.create();
                alertDialog.show();
            }
        });
        Display.getInstance().invokeAndBlock(pickInstance);
        if (canceled[0]) {
            return null;
        }
        if (pickInstance.result < 0) {
            return null;
        }
        return values[pickInstance.result];
    }
    return null;
}