Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void showNumberPickerDialog( String title, int value, String unit)
- {
- final Dialog d = new Dialog(getActivity());
- d.setTitle(title);
- d.setContentView(R.layout.dialog_numberpick);
- Button btnOk = (Button) d.findViewById(R.id.btn_ok);
- Button btnCancel = (Button) d.findViewById(R.id.btn_cancel);
- int iH = (value / 100) % 100;
- int iZ = (value / 10) % 10;
- int iE = value % 10;
- final NumberPicker np0 = (NumberPicker) d.findViewById(R.id.numberPicker0);
- final NumberPicker np1 = (NumberPicker) d.findViewById(R.id.numberPicker1);
- final NumberPicker np2 = (NumberPicker) d.findViewById(R.id.numberPicker2);
- final TextView unt = (TextView) d.findViewById(R.id.unit);
- np0.setMaxValue(9);
- np0.setMinValue(0);
- np1.setMaxValue(9);
- np1.setMinValue(0);
- np2.setMaxValue(9);
- np2.setMinValue(0);
- np0.setValue(iE);
- np1.setValue(iZ);
- np2.setValue(iH);
- unt.setText(unit);
- np0.setWrapSelectorWheel(true);
- np1.setWrapSelectorWheel(true);
- np2.setWrapSelectorWheel(true);
- btnOk.setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v) {
- Log.d(LOG_TAG, "btnOK click.");
- int aVal = np0.getValue() + (np1.getValue()*10) + (np2.getValue()*100);
- //do something with aVal
- d.dismiss();
- }
- });
- btnCancel.setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v) {
- Log.d(LOG_TAG, "btnCancel click.");
- d.dismiss();
- }
- });
- d.show();
- }
- // Dialog DoEdit
- public void showMyEditDialog( DsFi f )
- {
- final Dialog d = new Dialog(this, R.style.Dlg);
- d.setTitle("My Title");
- d.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
- d.setContentView(R.layout.activity_dlg_edit);
- Button btnClose = (Button) d.findViewById(R.id.dfe_btn_close);
- TextView tvStartNum = (TextView) d.findViewById(R.id.dfe_txt_startnum);
- TextView tvEndNum = (TextView) d.findViewById(R.id.dfe_txt_endnum);
- TextView tvDuration = (TextView) d.findViewById(R.id.dfe_txt_duration);
- tvStartNum.setText(String.format("%d", f.getStartNum()) );
- tvEndNum.setText(String.format("%d", f.getEndNum()) );
- tvDuration.setText(String.format("%d", f.getDuration()) );
- btnClose.setOnClickListener(new View.OnClickListener()
- {
- @Override
- public void onClick(View v) {
- Log.d(LOG_TAG, "btnReload click.");
- }
- });
- // this is fiction, but thats how i want to use my MyNumPickerDialog class.
- final MyNumPickerDialog dlgNP = new MyNumPickerDialog(this, new MyNumPickerDialog.OnNumSetListener() {
- public void onNumSet(NumPickerDialog view, int num) {
- tvStartNum.setText(String.format("%d", num()) );
- }
- };
- // end fiction
- tvStartNum.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View vi) {
- String sNum = tvStartNum.getText().toString();
- int n = Integer.parseInt(sNum);
- // fiction ...
- dlgNP.updateNum(n);
- dlgNP.show();
- }
- });
- d.show();
- }
Add Comment
Please, Sign In to add comment