Example usage for android.app AlertDialog setView

List of usage examples for android.app AlertDialog setView

Introduction

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

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:in.animeshpathak.nextbus.NextBusMain.java

/** Called when the activity is first started. */
@Override//from  w w w.j  ava  2 s . c  o  m
public void onCreate(Bundle bundle) {
    Log.d(LOG_TAG, "entering onCreate()");
    SettingsActivity.setTheme(this);
    super.onCreate(bundle);
    setContentView(R.layout.main);

    try {
        busNet = BusNetwork.getInstance(this);
    } catch (Exception e) {
        Log.e(LOG_TAG, e.getMessage(), e);
        return;
    }

    // get the button
    // set handler to launch a processing dialog
    ImageButton updateButton = (ImageButton) findViewById(R.id.update_button);
    updateButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            BusLine selectedLine = lineAdapter.getItem(lineSpinner.getSelectedItemPosition());
            BusStop selectedStop = stopAdapter.getItem(stopSpinner.getSelectedItemPosition());
            getBusTimings(selectedLine, selectedStop);
        }
    });

    ImageButton feedbackButton = (ImageButton) findViewById(R.id.feedback_button);
    feedbackButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Intent.ACTION_SEND);
            i.setType("message/rfc822"); // use from live device
            i.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.FEEDBACK_EMAIL_ADDRESS });
            i.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_EMAIL_SUBJECT);
            i.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_hello));
            startActivity(Intent.createChooser(i, getString(R.string.select_email_app)));
        }
    });

    ImageButton phebusinfoButton = (ImageButton) findViewById(R.id.phebusinfo_button);
    phebusinfoButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            AlertDialog alertDialog = new AlertDialog.Builder(NextBusMain.this).create();
            WebView wv = new WebView(NextBusMain.this);
            new PhebusNewsLoader(wv, NextBusMain.this).execute();
            alertDialog.setView(wv);
            alertDialog.show();
        }
    });

    lineSpinner = (Spinner) findViewById(R.id.line_spinner);
    lineAdapter = new ArrayAdapter<BusLine>(this, android.R.layout.simple_spinner_item, busNet.getLines());
    lineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    lineSpinner.setAdapter(lineAdapter);

    stopSpinner = (Spinner) findViewById(R.id.stop_spinner);
    stopAdapter = new ArrayAdapter<BusStop>(this, android.R.layout.simple_spinner_item);
    stopAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    stopSpinner.setAdapter(stopAdapter);

    ImageButton favoriteButton = (ImageButton) findViewById(R.id.favorites_button);
    favoriteButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            new FavoriteDialog(NextBusMain.this, new OnFavoriteSelectedListener() {
                @Override
                public void favoriteSelected(Favorite fav) {
                    BusLine bl = busNet.getLineByName(fav.getLine());
                    BusStop bs = bl.getFirstStopWithSimilarName(fav.getStop());
                    if (bl == null || bs == null) {
                        Log.e(LOG_TAG, "Favorite not found!");
                        return;
                    }
                    updateSpinners(bl, bs);
                    getBusTimings(bl, bs);
                }
            }, lineSpinner.getSelectedItem().toString(), stopSpinner.getSelectedItem().toString());
        }
    });
}

From source file:com.itude.mobile.mobbl.core.controller.util.MBBasicViewController.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    _isDialogClosable = getArguments().getBoolean("closable", false);
    _isDialogFullscreen = getArguments().getBoolean("fullscreen", false);
    _isDialogCancelable = getArguments().getBoolean("cancelable", false) || _isDialogCancelable;

    if (_isDialogClosable) {
        ViewGroup view = buildInitialView(LayoutInflater.from(getActivity()));

        /*//from   w ww  .j  a  v a 2  s  . com
         * Add this view and a close button to a wrapper view that will be used as the content view of our AlertDialog
         */

        // unable to use the holo light theme as pre honeycomb doesn't know AlertDialog.Builder(context, theme) 
        AlertDialog.Builder adb = new AlertDialog.Builder(getActivity());
        AlertDialog dialog = adb.create();

        View content = addCloseButtonToClosableDialogView(view, dialog);

        dialog.setView(content);

        dialog.setOnKeyListener(new OnKeyListener() {

            @Override
            public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
                if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_BACK) {
                    return onBackKeyPressed();
                }

                return false;
            }
        });

        return dialog;
    }

    if (_isDialogFullscreen) {
        setStyle(STYLE_NO_TITLE, android.R.style.Theme);
    }

    return super.onCreateDialog(savedInstanceState);
}

From source file:com.example.parking.ParkingInformationActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mDBAdapter = new DBAdapter(this);
    setContentView(R.layout.activity_parking_information);
    mParkNameTV = (TextView) findViewById(R.id.tv_parking_name);
    mParkNameTV.setText(R.string.park_name_fixed);
    mParkNumberTV = (TextView) findViewById(R.id.tv_parking_number);
    mParkNumberTV.setText("?:" + this.getString(R.string.park_number_fixed));
    mCarType = (Spinner) findViewById(R.id.sp_car_type);
    mParkingType = (Spinner) findViewById(R.id.sp_parking_type);
    mLocationNumber = (Spinner) findViewById(R.id.sp_parking_location);
    mLicensePlateNumberTV = (TextView) findViewById(R.id.tv_license_plate_number);
    Intent intent = getIntent();//from w  w  w . ja va2s. c  o  m
    Bundle bundle = intent.getExtras();
    mLicensePlateNumberTV.setText(bundle.getString("licensePlate"));
    mStartTime = (TextView) findViewById(R.id.tv_start_time_arriving);
    new TimeThread().start();
    mOkButton = (Button) findViewById(R.id.bt_confirm_arriving);
    mOkButton.setOnClickListener(new InsertOnclickListener(mLicensePlateNumberTV.getText().toString(),
            mCarType.getSelectedItem().toString(), mParkingType.getSelectedItem().toString(),
            Integer.parseInt(mLocationNumber.getSelectedItem().toString()),
            DateFormat.format("yyyy-MM-dd HH:mm:ss", System.currentTimeMillis()).toString(), null, null,
            ""));
    mPhotoBT = (Button) findViewById(R.id.bt_camera_arriving);
    mPhotoBT.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mEnterImage != null) {
                Toast.makeText(getApplicationContext(), "?", Toast.LENGTH_SHORT)
                        .show();
            } else {
                openTakePhoto();
            }
        }
    });
    mPhotoTitleTV = (TextView) findViewById(R.id.tv_photo_title_arriving);
    mEnterImageIV = (ImageView) findViewById(R.id.iv_photo_arriving);
    mEnterImageIV.setOnClickListener(new Button.OnClickListener() {
        @Override
        public void onClick(View v) {
            LayoutInflater inflater = LayoutInflater.from(getApplicationContext());
            View imgEntryView = inflater.inflate(R.layout.dialog_photo_entry, null); // 
            final AlertDialog dialog = new AlertDialog.Builder(ParkingInformationActivity.this).create();
            ImageView img = (ImageView) imgEntryView.findViewById(R.id.iv_large_image);
            Button deleteBT = (Button) imgEntryView.findViewById(R.id.bt_delete_image);
            img.setImageBitmap(mEnterImage);
            dialog.setView(imgEntryView); // dialog
            dialog.show();
            imgEntryView.setOnClickListener(new OnClickListener() {
                public void onClick(View paramView) {
                    dialog.cancel();
                }
            });
            deleteBT.setOnClickListener(new OnClickListener() {
                public void onClick(View paramView) {
                    mEnterImage = null;
                    mEnterImageIV.setImageResource(drawable.ic_photo_background_64px);
                    dialog.cancel();
                }
            });
        }
    });
    getActionBar().setDisplayHomeAsUpEnabled(true);
    IntentFilter filter = new IntentFilter();
    filter.addAction("ExitApp");
    registerReceiver(mReceiver, filter);
}

From source file:ca.ualberta.app.activity.CreateQuestionActivity.java

public void viewQuestionImage(View view) {
    LayoutInflater inflater = LayoutInflater.from(view.getContext());
    View imgEntryView = inflater.inflate(R.layout.dialog_photo, null);
    final AlertDialog dialog = new AlertDialog.Builder(view.getContext()).create();
    ImageView img = (ImageView) imgEntryView.findViewById(R.id.large_image);
    img.setImageBitmap(image);/*w w w . j a  v  a2s  . co  m*/
    dialog.setView(imgEntryView);
    dialog.show();
    imgEntryView.setOnClickListener(new OnClickListener() {
        public void onClick(View paramView) {
            dialog.cancel();
        }
    });
}

From source file:org.uclab.mm.sl.uiux.uiuxanalyticsdemo.MainActivity.java

public void userFeedback() {
    AlertDialog userfeedback = new AlertDialog.Builder(this).create();

    // Setting Dialog Title
    userfeedback.setTitle("Feedback");

    // Setting Icon to Dialog
    userfeedback.setIcon(R.drawable.ic_feedback_black_18dp);

    LayoutInflater inflater = this.getLayoutInflater();

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    userfeedback.setView(inflater.inflate(R.layout.feedback, null));

    // Setting OK Button
    userfeedback.setButton("Send", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {
            // Write your code here to execute after dialog
            // closed
            Toast.makeText(getApplicationContext(), "Your Feedback sent Successfully", Toast.LENGTH_SHORT)
                    .show();// www  .  j  a v a2  s .c o m
        }
    });

    // Showing Alert Message
    userfeedback.show();
}

From source file:group.pals.android.lib.ui.filechooser.utils.ui.bookmark.BookmarkFragment.java

/**
 * Shows a dialog to let user enter new name or change current name of a
 * bookmark.//from ww  w .  j  a  va2 s.c om
 * 
 * @param context
 *            {@link Context}
 * @param providerId
 *            the provider ID.
 * @param id
 *            the bookmark ID.
 * @param uri
 *            the URI to the bookmark.
 * @param name
 *            the name. To enter new name, this is the suggested name you
 *            provide. To rename, this is the old name.
 */
public static void doEnterNewNameOrRenameBookmark(final Context context, final String providerId, final int id,
        final Uri uri, final String name) {
    final AlertDialog dialog = Dlg.newDlg(context);

    View view = LayoutInflater.from(context).inflate(R.layout.afc_simple_text_input_view, null);
    final EditText textName = (EditText) view.findViewById(R.id.afc_text1);
    textName.setText(name);
    textName.selectAll();
    textName.setHint(R.string.afc_hint_new_name);
    textName.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                Ui.showSoftKeyboard(textName, false);
                Button btn = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (btn.isEnabled())
                    btn.performClick();
                return true;
            }
            return false;
        }// onEditorAction()
    });

    dialog.setView(view);
    dialog.setIcon(R.drawable.afc_bookmarks_dark);
    dialog.setTitle(id < 0 ? R.string.afc_title_new_bookmark : R.string.afc_title_rename);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String newName = textName.getText().toString().trim();
                    if (android.text.TextUtils.isEmpty(newName)) {
                        Dlg.toast(context, R.string.afc_msg_bookmark_name_is_invalid, Dlg._LengthShort);
                        return;
                    }

                    Ui.showSoftKeyboard(textName, false);

                    ContentValues values = new ContentValues();
                    values.put(BookmarkContract.Bookmark._ColumnName, newName);

                    if (id >= 0) {
                        values.put(BookmarkContract.Bookmark._ColumnModificationTime,
                                DbUtils.formatNumber(new Date().getTime()));
                        context.getContentResolver()
                                .update(Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase,
                                        Uri.encode(Integer.toString(id))), values, null, null);
                    } else {
                        /*
                         * Check if the URI exists or doesn't. If it exists,
                         * update it instead of inserting the new one.
                         */
                        Cursor cursor = context.getContentResolver().query(
                                BookmarkContract.Bookmark._ContentUri, null,
                                String.format("%s = %s AND %s LIKE %s",
                                        BookmarkContract.Bookmark._ColumnProviderId,
                                        DatabaseUtils.sqlEscapeString(providerId),
                                        BookmarkContract.Bookmark._ColumnUri,
                                        DatabaseUtils.sqlEscapeString(uri.toString())),
                                null, null);
                        try {
                            if (cursor != null && cursor.moveToFirst()) {
                                values.put(BookmarkContract.Bookmark._ColumnModificationTime,
                                        DbUtils.formatNumber(new Date().getTime()));
                                context.getContentResolver().update(
                                        Uri.withAppendedPath(BookmarkContract.Bookmark._ContentIdUriBase,
                                                Uri.encode(cursor.getString(
                                                        cursor.getColumnIndex(BookmarkContract.Bookmark._ID)))),
                                        values, null, null);
                            } else {
                                values.put(BookmarkContract.Bookmark._ColumnProviderId, providerId);
                                values.put(BookmarkContract.Bookmark._ColumnUri, uri.toString());

                                context.getContentResolver().insert(BookmarkContract.Bookmark._ContentUri,
                                        values);
                            }
                        } finally {
                            if (cursor != null)
                                cursor.close();
                        }
                    }

                    Dlg.toast(context, context.getString(R.string.afc_msg_done), Dlg._LengthShort);
                }// onClick()
            });

    dialog.show();
    Ui.showSoftKeyboard(textName, true);

    final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    buttonOk.setEnabled(id < 0);

    textName.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            String newName = s.toString().trim();
            boolean enabled = !android.text.TextUtils.isEmpty(newName);
            buttonOk.setEnabled(enabled);

            /*
             * If renaming, only enable button OK if new name is not equal
             * to the old one.
             */
            if (enabled && id >= 0)
                buttonOk.setEnabled(!newName.equals(name));
        }
    });
}

From source file:ca.ualberta.app.activity.CreateAnswerActivity.java

/**
 * set the image to the imageView//  w  w  w.  j a va  2s .  co  m
 * 
 * @param view
 *            View passed to the activity to check which button was pressed.
 */
// http://www.csdn123.com/html/mycsdn20140110/2d/2d3c6d5adb428b6708901f7060d31800.html
public void viewAnswerImage(View view) {
    LayoutInflater inflater = LayoutInflater.from(view.getContext());
    View imgEntryView = inflater.inflate(R.layout.dialog_photo, null);
    final AlertDialog dialog = new AlertDialog.Builder(view.getContext()).create();
    ImageView img = (ImageView) imgEntryView.findViewById(R.id.large_image);
    img.setImageBitmap(image);
    dialog.setView(imgEntryView);
    dialog.show();
    imgEntryView.setOnClickListener(new OnClickListener() {
        public void onClick(View paramView) {
            dialog.cancel();
        }
    });
}

From source file:no.barentswatch.fiskinfo.MapActivity.java

public void showProximityAlertDialog(Context activityContext) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.dialog_proximity_alert, null);
    final AlertDialog builder = new AlertDialog.Builder(activityContext).create();
    builder.setTitle(R.string.map_proximity_alert_title);
    builder.setView(view);

    Button goToMyPositionButton = (Button) view.findViewById(R.id.proximityAlertViewPositionButton);
    Button cancelProximityAlert = (Button) view.findViewById(R.id.proximityAlertCancelButton);
    builder.setView(view);//  w  w w.  j a  v a 2s  .co m

    goToMyPositionButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            builder.dismiss();
            browser.loadUrl("javascript:zoomToUserPosition()");
        }
    });

    cancelProximityAlert.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO: stop alert

            builder.dismiss();
        }
    });

    builder.show();
}

From source file:com.haibison.android.anhuu.utils.ui.bookmark.BookmarkFragment.java

/**
 * Shows a dialog to let the user enter new name or change current name of a
 * bookmark.//from  w w w.j a va  2s .c  om
 * 
 * @param context
 *            {@link Context}
 * @param providerId
 *            the provider ID.
 * @param id
 *            the bookmark ID.
 * @param uri
 *            the URI to the bookmark.
 * @param name
 *            the name. To enter new name, this is the suggested name you
 *            provide. To rename, this is the old name.
 */
public static void doEnterNewNameOrRenameBookmark(final Context context, final String providerId, final int id,
        final Uri uri, final String name) {
    final AlertDialog dialog = Dlg.newAlertDlg(context);

    View view = LayoutInflater.from(context).inflate(R.layout.anhuu_f5be488d_simple_text_input_view, null);
    final EditText textName = (EditText) view.findViewById(R.id.anhuu_f5be488d_text1);
    textName.setText(name);
    textName.selectAll();
    textName.setHint(R.string.anhuu_f5be488d_hint_new_name);
    textName.setOnEditorActionListener(new TextView.OnEditorActionListener() {

        @Override
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            if (actionId == EditorInfo.IME_ACTION_DONE) {
                UI.showSoftKeyboard(textName, false);
                Button btn = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
                if (btn.isEnabled())
                    btn.performClick();
                return true;
            }
            return false;
        }// onEditorAction()
    });

    dialog.setView(view);
    dialog.setIcon(R.drawable.anhuu_f5be488d_bookmarks_dark);
    dialog.setTitle(id < 0 ? R.string.anhuu_f5be488d_title_new_bookmark : R.string.anhuu_f5be488d_title_rename);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    String newName = textName.getText().toString().trim();
                    if (android.text.TextUtils.isEmpty(newName)) {
                        Dlg.toast(context, R.string.anhuu_f5be488d_msg_bookmark_name_is_invalid,
                                Dlg.LENGTH_SHORT);
                        return;
                    }

                    UI.showSoftKeyboard(textName, false);

                    ContentValues values = new ContentValues();
                    values.put(BookmarkContract.COLUMN_NAME, newName);

                    if (id >= 0) {
                        values.put(BookmarkContract.COLUMN_MODIFICATION_TIME,
                                DbUtils.formatNumber(new Date().getTime()));
                        context.getContentResolver().update(
                                ContentUris.withAppendedId(BookmarkContract.genContentIdUriBase(context), id),
                                values, null, null);
                    } else {
                        /*
                         * Check if the URI exists or doesn't. If it exists,
                         * update it instead of inserting the new one.
                         */
                        Cursor cursor = context.getContentResolver().query(
                                BookmarkContract.genContentUri(context), null,
                                String.format("%s = %s AND %s LIKE %s", BookmarkContract.COLUMN_PROVIDER_ID,
                                        DatabaseUtils.sqlEscapeString(providerId), BookmarkContract.COLUMN_URI,
                                        DatabaseUtils.sqlEscapeString(uri.toString())),
                                null, null);
                        try {
                            if (cursor != null && cursor.moveToFirst()) {
                                values.put(BookmarkContract.COLUMN_MODIFICATION_TIME,
                                        DbUtils.formatNumber(new Date().getTime()));
                                context.getContentResolver().update(
                                        Uri.withAppendedPath(BookmarkContract.genContentIdUriBase(context),
                                                Uri.encode(cursor.getString(
                                                        cursor.getColumnIndex(BookmarkContract._ID)))),
                                        values, null, null);
                            } else {
                                values.put(BookmarkContract.COLUMN_PROVIDER_ID, providerId);
                                values.put(BookmarkContract.COLUMN_URI, uri.toString());

                                context.getContentResolver().insert(BookmarkContract.genContentUri(context),
                                        values);
                            }
                        } finally {
                            if (cursor != null)
                                cursor.close();
                        }
                    }

                    Dlg.toast(context, context.getString(R.string.anhuu_f5be488d_msg_done), Dlg.LENGTH_SHORT);
                }// onClick()
            });

    dialog.show();
    UI.showSoftKeyboard(textName, true);

    final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    buttonOk.setEnabled(id < 0);

    textName.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // TODO Auto-generated method stub
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }

        @Override
        public void afterTextChanged(Editable s) {
            String newName = s.toString().trim();
            boolean enabled = !android.text.TextUtils.isEmpty(newName);
            buttonOk.setEnabled(enabled);

            /*
             * If renaming, only enable button OK if new name is not equal
             * to the old one.
             */
            if (enabled && id >= 0)
                buttonOk.setEnabled(!newName.equals(name));
        }
    });
}

From source file:no.barentswatch.fiskinfo.MapActivity.java

/**
 * //from  w ww . j  a  va2s .  co m
 * @param activityContext
 *            The context of the current activity
 */
@SuppressLint("InflateParams")
public void setProximityAlertDialog(Context activityContext) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.dialog_scheduled_task_executor, null);
    final AlertDialog builder = new AlertDialog.Builder(activityContext).create();
    builder.setTitle(R.string.map_set_proximity_alert_title);
    builder.setView(view);

    final EditText distanceEditText = (EditText) view.findViewById(R.id.scheduledProximityRangeEditText);
    final SeekBar seekbar = (SeekBar) view.findViewById(R.id.scheduledSetProximityRangeSeekBar);
    distanceEditText.setText(String.valueOf(minLenghtMeters));

    final Spinner measuringUnitSpinner = (Spinner) view.findViewById(R.id.scheduledMeasuringUnitsSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.measurement_units,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    measuringUnitSpinner.setAdapter(adapter);

    seekbar.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {
        }

        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser == true) {
                if (currentlySelected == meterIndex) {
                    distanceEditText
                            .setText(String.valueOf((int) (minLenghtMeters + (stepSizeMeters * progress))));
                } else if (currentlySelected == nauticalMileIndex) {
                    distanceEditText.setText(
                            String.valueOf(minLenghtNauticalMiles + (stepSizeNauticalMiles * progress)));
                }
            }
        }
    });

    measuringUnitSpinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            double distance = (distanceEditText.length() != 0
                    ? Double.parseDouble(distanceEditText.getText().toString())
                    : 0);

            System.out.println("posistion: " + position);
            System.out.println("currentlySelected: " + position);

            if (position == meterIndex) {
                if (position != currentlySelected) {
                    distance = convertDistance(distance, position);
                    distanceEditText.setText(String.valueOf(distance));
                    currentlySelected = position;
                }
            } else if (position == nauticalMileIndex) {
                if (position != currentlySelected) {
                    distance = convertDistance(distance, position);
                    distanceEditText.setText(String.valueOf(distance));
                    currentlySelected = position;
                }
            } else {
                return;
            }
            System.out.println("distance: " + distance);

            int newProgress = findProgress(distance, position);
            seekbar.setProgress(newProgress);
            System.out.println("progress: " + newProgress);
            distanceEditText.setText(String.valueOf(distance));
        }

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

    Button setProximityAlertButton = (Button) view.findViewById(R.id.scheduledSetProximityCheckerDialogButton);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);

    builder.setView(view);
    builder.setCanceledOnTouchOutside(false);

    setProximityAlertButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            if (!alarmSet) {
                mGpsLocationTracker = new GpsLocationTracker(getContext());
                double latitude, longitude = 0;
                if (mGpsLocationTracker.canGetLocation()) {
                    latitude = mGpsLocationTracker.getLatitude();
                    cachedLat = latitude;
                    longitude = mGpsLocationTracker.getLongitude();
                    cachedLon = longitude;
                } else {
                    mGpsLocationTracker.showSettingsAlert();
                    return;
                }
                String distance = distanceEditText.getText().toString();
                cachedDistance = distance;

                cacheWriter = new DownloadMapLayerFromBarentswatchApiInBackground().execute("fishingfacility",
                        "OLEX", "cachedResults", String.valueOf(longitude), String.valueOf(latitude), distance,
                        "true");
                alarmSet = true;
                runScheduledAlarm();
            }

            builder.dismiss();
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            builder.cancel();

        }
    });

    builder.show();
}