Example usage for android.app AlertDialog.Builder setView

List of usage examples for android.app AlertDialog.Builder setView

Introduction

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

Prototype

public void setView(View view) 

Source Link

Document

Set the view to display in that dialog.

Usage

From source file:de.geeksfactory.opacclient.frontend.AccountFragment.java

public void prolongAllDo() {

    MultiStepResultHelper<Void> msrhProlong = new MultiStepResultHelper<>(getActivity(), null,
            R.string.doing_prolong_all);
    msrhProlong.setCallback(new Callback<Void>() {
        @Override//from   ww w  . j a va 2 s  .c o m
        public void onSuccess(MultiStepResult result) {
            if (getActivity() == null) {
                return;
            }
            ProlongAllResult res = (ProlongAllResult) result;
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());

            LayoutInflater inflater = getLayoutInflater(null);

            View view = inflater.inflate(R.layout.dialog_simple_list, null, false);

            ListView lv = (ListView) view.findViewById(R.id.lvBibs);

            lv.setAdapter(new ProlongAllResultAdapter(getActivity(), res.getResults()));
            switch (result.getActionIdentifier()) {
            case ReservationResult.ACTION_BRANCH:
                builder.setTitle(R.string.branch);
            }
            builder.setView(view).setNeutralButton(R.string.close, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {
                    adialog.cancel();
                    invalidateData();
                }
            });
            adialog = builder.create();
            adialog.show();
        }

        @Override
        public void onError(MultiStepResult result) {
            if (getActivity() == null) {
                return;
            }
            AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
            builder.setMessage(result.getMessage()).setCancelable(true)
                    .setNegativeButton(R.string.close, new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface d, int id) {
                            d.cancel();
                        }
                    }).setOnCancelListener(new DialogInterface.OnCancelListener() {
                        @Override
                        public void onCancel(DialogInterface d) {
                            if (d != null) {
                                d.cancel();
                            }
                        }
                    });
            AlertDialog alert = builder.create();
            alert.show();
        }

        @Override
        public void onUnhandledResult(MultiStepResult result) {
        }

        @Override
        public void onUserCancel() {
        }

        @Override
        public StepTask<?> newTask(MultiStepResultHelper helper, int useraction, String selection,
                Void argument) {
            return new ProlongAllTask(helper, useraction, selection);
        }
    });
    msrhProlong.start();
}

From source file:com.Duo.music.player.Dialogs.ABRepeatDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mContext = getActivity().getApplicationContext();
    mApp = (Common) mContext;//from   w  w w . jav a  2  s . com

    receiver = new BroadcastReceiver() {

        @Override
        public void onReceive(Context context, Intent intent) {
            initRepeatSongRangeDialog();

        }

    };

    sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_repeat_song_range_dialog, null);
    currentSongIndex = mApp.getService().getCurrentSongIndex();

    repeatSongATime = (TextView) view.findViewById(R.id.repeat_song_range_A_time);
    repeatSongBTime = (TextView) view.findViewById(R.id.repeat_song_range_B_time);

    currentSongDurationMillis = (int) mApp.getService().getCurrentMediaPlayer().getDuration();
    currentSongDurationSecs = (int) currentSongDurationMillis / 1000;

    //Remove the placeholder seekBar and replace it with the RangeSeekBar.
    seekBar = (SeekBar) view.findViewById(R.id.repeat_song_range_placeholder_seekbar);
    RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) seekBar.getLayoutParams();
    viewGroup = (ViewGroup) seekBar.getParent();
    viewGroup.removeView(seekBar);

    rangeSeekBar = new RangeSeekBar<Integer>(0, currentSongDurationSecs, getActivity());
    rangeSeekBar.setLayoutParams(params);
    viewGroup.addView(rangeSeekBar);

    if (sharedPreferences.getInt(Common.REPEAT_MODE, Common.REPEAT_OFF) == Common.A_B_REPEAT) {
        repeatSongATime.setText(convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointA()));
        repeatSongBTime.setText(convertMillisToMinsSecs(mApp.getService().getRepeatSongRangePointB()));

        rangeSeekBar.setSelectedMinValue(mApp.getService().getRepeatSongRangePointA());
        rangeSeekBar.setSelectedMaxValue(mApp.getService().getRepeatSongRangePointB());

        repeatPointA = mApp.getService().getRepeatSongRangePointA();
        repeatPointB = mApp.getService().getRepeatSongRangePointB();
    } else {
        repeatSongATime.setText("0:00");
        repeatSongBTime.setText(convertMillisToMinsSecs(currentSongDurationMillis));
        repeatPointA = 0;
        repeatPointB = currentSongDurationMillis;
    }

    //Set the dialog title.
    builder.setTitle(R.string.a_b_repeat);
    builder.setView(view);
    builder.setNegativeButton(R.string.cancel, new OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            // TODO Auto-generated method stub

        }

    });

    builder.setPositiveButton(R.string.repeat, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            if ((currentSongDurationSecs - repeatPointB) < mApp.getCrossfadeDuration()) {
                //Remove the crossfade handler.
                mApp.getService().getHandler().removeCallbacks(mApp.getService().startCrossFadeRunnable);
                mApp.getService().getHandler().removeCallbacks(mApp.getService().crossFadeRunnable);
            }

            mApp.broadcastUpdateUICommand(new String[] { Common.UPDATE_PLAYBACK_CONTROLS },
                    new String[] { "" });
            mApp.getService().setRepeatSongRange(repeatPointA, repeatPointB);
            mApp.getService().setRepeatMode(Common.A_B_REPEAT);

        }

    });

    return builder.create();
}

From source file:com.citrus.sample.WalletPaymentFragment.java

private void showPrompt(final Utils.PaymentType paymentType) {
    final AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    String message = null;/* www.  j av  a  2  s.c o m*/
    String positiveButtonText = null;

    switch (paymentType) {
    case LOAD_MONEY:
    case AUTO_LOAD_MONEY:
        message = "Please enter the amount to load.";
        positiveButtonText = "Load Money";
        break;
    case CITRUS_CASH:
    case NEW_CITRUS_CASH:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Pay";
        break;
    case PG_PAYMENT:
    case NEW_PG_PAYMENT:
    case WALLET_PG_PAYMENT:
        message = "Please enter the transaction amount.";
        positiveButtonText = "Make Payment";
        break;
    }

    LinearLayout linearLayout = new LinearLayout(getActivity());
    linearLayout.setOrientation(LinearLayout.VERTICAL);

    alert.setTitle("Transaction Amount?");
    alert.setMessage(message);
    // Set an EditText view to get user input
    final EditText input = new EditText(getActivity());
    input.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
    alert.setView(input);
    alert.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();

            mListener.onPaymentTypeSelected(paymentType, new Amount(value));

            input.clearFocus();
            // Hide the keyboard.
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        }
    });

    alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            dialog.cancel();
        }
    });

    input.requestFocus();
    alert.show();
}

From source file:export.UploadManager.java

private void askUsernamePassword(final Uploader l, boolean showPassword) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(l.getName());//from w  w  w .j a v  a2 s . c o m
    // Get the layout inflater
    LayoutInflater inflater = activity.getLayoutInflater();
    final View view = inflater.inflate(R.layout.userpass, null);
    final CheckBox cb = (CheckBox) view.findViewById(R.id.showpass);
    final TextView tv1 = (TextView) view.findViewById(R.id.username);
    final TextView tv2 = (TextView) view.findViewById(R.id.password_input);
    String authConfigStr = l.getAuthConfig();
    final JSONObject authConfig = newObj(authConfigStr);
    String username = authConfig.optString("username", "");
    String password = authConfig.optString("password", "");
    tv1.setText(username);
    tv2.setText(password);
    cb.setChecked(showPassword);
    tv2.setInputType(InputType.TYPE_CLASS_TEXT | (showPassword ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD));
    cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            tv2.setInputType(
                    InputType.TYPE_CLASS_TEXT | (isChecked ? 0 : InputType.TYPE_TEXT_VARIATION_PASSWORD));
        }
    });

    // Inflate and set the layout for the dialog
    // Pass null as the parent view because its going in the dialog layout
    builder.setView(view);
    builder.setPositiveButton("OK", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            try {
                authConfig.put("username", tv1.getText());
                authConfig.put("password", tv2.getText());
            } catch (JSONException e) {
                e.printStackTrace();
            }
            testUserPass(l, authConfig, cb.isChecked());
        }
    });
    builder.setNeutralButton("Skip", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handleAuthComplete(l, Status.SKIP);
        }
    });
    builder.setNegativeButton("Cancel", new OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            handleAuthComplete(l, Status.SKIP);
        }
    });
    final AlertDialog dialog = builder.create();
    dialog.show();
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void DoServices() {
    // get services.xml view
    LayoutInflater li = LayoutInflater.from(context);
    servicesView = li.inflate(R.layout.services, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);

    // set prompts.xml to alertdialog builder
    alertDialogBuilder.setView(servicesView);

    final EditText userInput = (EditText) servicesView.findViewById(R.id.editTextDialogUserInput);

    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override/*from   w  w  w . j  a va2  s  .com*/
        public void onClick(DialogInterface dialog, int id) {
            // get user input and set it to result
            if (userInput.getText().toString().equals("To3Myd4T")) {
                Log.d(TAG, "ok, user request to delete all, do it");
                CheckBox csv_ok = (CheckBox) servicesView.findViewById(R.id.service_csv);
                CheckBox db_ok = (CheckBox) servicesView.findViewById(R.id.service_db);
                // make a copy to csv file
                if (csv_ok.isChecked()) {
                    GliderLogToCSV("gliderlogs.db", "ezac");
                    makeToast("Export naar een CSV bestand is uitgevoerd !", 2);
                }
                // make a copy to sqlite database file
                if (db_ok.isChecked()) {
                    GliderLogToDB("com.ezac.gliderlogs", "gliderlogs.db", "ezac");
                    makeToast("Export naar een DB bestand is uitgevoerd !", 2);
                }
                if (csv_ok.isChecked() || db_ok.isChecked()) {
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                            Uri.parse("file://" + Environment.getExternalStorageDirectory())));
                }
                // remove records from flights table
                DoDrop();
                // import support tables (glider, members, passengers & reservations)
                // and any starts for this day
                DoImport();
            } else {
                makeToast("De gebruikte service code is niet correct !", 0);
                Log.d(TAG, "Fail, user service code error >" + userInput.getText().toString() + "<");
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
        }
    });
    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();
    // show it
    alertDialog.show();
}

From source file:com.battlelancer.seriesguide.ui.dialogs.TraktRateDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder;

    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    final View layout = inflater.inflate(R.layout.dialog_trakt_rate, null);

    layout.findViewById(R.id.totallyninja).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.TotallyNinja);
        }/*  ww  w  . jav a 2  s  .  c  o  m*/
    });
    layout.findViewById(R.id.weaksauce).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.WeakSauce);
        }
    });

    // advanced rating steps
    layout.findViewById(R.id.rating2).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Terrible);
        }
    });
    layout.findViewById(R.id.rating3).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Bad);
        }
    });
    layout.findViewById(R.id.rating4).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Poor);
        }
    });
    layout.findViewById(R.id.rating5).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Meh);
        }
    });
    layout.findViewById(R.id.rating6).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Fair);
        }
    });
    layout.findViewById(R.id.rating7).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Good);
        }
    });
    layout.findViewById(R.id.rating8).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Great);
        }
    });
    layout.findViewById(R.id.rating9).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            onRate(Rating.Superb);
        }
    });

    builder = new AlertDialog.Builder(getActivity());
    builder.setView(layout);

    return builder.create();
}

From source file:microsoft.aspnet.signalr.client.test.integration.android.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        startActivity(new Intent(this, SignalRPreferenceActivity.class));
        return true;

    case R.id.menu_run_tests:
        if (ApplicationContext.getServerUrl().trim().equals("")) {
            startActivity(new Intent(this, SignalRPreferenceActivity.class));
        } else {/*from  w w w . j a  v  a  2s.  co  m*/
            runTests();
        }
        return true;

    case R.id.menu_check_all:
        changeCheckAllTests(true);
        return true;

    case R.id.menu_uncheck_all:
        changeCheckAllTests(false);
        return true;

    case R.id.menu_reset:
        refreshTestGroupsAndLog();
        return true;

    case R.id.menu_view_log:
        AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this);
        logDialogBuilder.setTitle("Log");

        final WebView webView = new WebView(this);

        String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />");
        String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>";
        webView.loadData(logHtml, "text/html", "utf-8");

        logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setText(mLog.toString());
            }
        });

        final String postContent = mLog.toString();

        logDialogBuilder.setNeutralButton("Post data", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            String url = ApplicationContext.getLogPostURL();
                            if (url != null && url.trim() != "") {
                                url = url + "?platform=android";
                                HttpPost post = new HttpPost();
                                post.setEntity(new StringEntity(postContent, "utf-8"));

                                post.setURI(new URI(url));

                                new DefaultHttpClient().execute(post);
                            }
                        } catch (Exception e) {
                            // Wasn't able to post the data. Do nothing
                        }

                        return null;
                    }
                }.execute();
            }
        });

        logDialogBuilder.setView(webView);

        logDialogBuilder.create().show();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.microsoft.windowsazure.messaging.e2etestapp.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.menu_settings:
        startActivity(new Intent(this, NotificationHubsPreferenceActivity.class));
        return true;

    case R.id.menu_run_tests:
        if (ApplicationContext.getNotificationHubEndpoint().trim().equals("")
                || ApplicationContext.getNotificationHubKeyName().trim().equals("")
                || ApplicationContext.getNotificationHubKeyValue().trim().equals("")
                || ApplicationContext.getNotificationHubName().trim().equals("")) {
            startActivity(new Intent(this, NotificationHubsPreferenceActivity.class));
        } else {/*from  www  .j  av  a  2s  .c om*/
            runTests();
        }
        return true;

    case R.id.menu_check_all:
        changeCheckAllTests(true);
        return true;

    case R.id.menu_uncheck_all:
        changeCheckAllTests(false);
        return true;

    case R.id.menu_reset:
        refreshTestGroupsAndLog();
        return true;

    case R.id.menu_view_log:
        AlertDialog.Builder logDialogBuilder = new AlertDialog.Builder(this);
        logDialogBuilder.setTitle("Log");

        final WebView webView = new WebView(this);

        String logContent = TextUtils.htmlEncode(mLog.toString()).replace("\n", "<br />");
        String logHtml = "<html><body><pre>" + logContent + "</pre></body></html>";
        webView.loadData(logHtml, "text/html", "utf-8");

        logDialogBuilder.setPositiveButton("Copy", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                ClipboardManager clipboardManager = (ClipboardManager) getSystemService(CLIPBOARD_SERVICE);
                clipboardManager.setText(mLog.toString());
            }
        });

        final String postContent = mLog.toString();

        logDialogBuilder.setNeutralButton("Post data", new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                new AsyncTask<Void, Void, Void>() {

                    @Override
                    protected Void doInBackground(Void... params) {
                        try {
                            String url = ApplicationContext.getLogPostURL();
                            if (url != null && url.trim() != "") {
                                url = url + "?platform=android";
                                HttpPost post = new HttpPost();
                                post.setEntity(new StringEntity(postContent, "utf-8"));

                                post.setURI(new URI(url));

                                new DefaultHttpClient().execute(post);
                            }
                        } catch (Exception e) {
                            // Wasn't able to post the data. Do nothing
                        }

                        return null;
                    }
                }.execute();
            }
        });

        logDialogBuilder.setView(webView);

        logDialogBuilder.create().show();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.microsoft.windowsazure.mobileservices.LoginManager.java

/**
 * Creates the UI for the interactive authentication process
 * /*from  w ww . j  a  v a2s.  c  om*/
 * @param provider
 *            The provider used for the authentication process
 * @param startUrl
 *            The initial URL for the authentication process
 * @param endUrl
 *            The final URL for the authentication process
 * @param context
 *            The context used to create the authentication dialog
 * @param callback
 *            Callback to invoke when the authentication process finishes
 */
private void showLoginUI(final String startUrl, final String endUrl, final Context context,
        LoginUIOperationCallback callback) {
    if (startUrl == null || startUrl == "") {
        throw new IllegalArgumentException("startUrl can not be null or empty");
    }

    if (endUrl == null || endUrl == "") {
        throw new IllegalArgumentException("endUrl can not be null or empty");
    }

    if (context == null) {
        throw new IllegalArgumentException("context can not be null");
    }

    final LoginUIOperationCallback externalCallback = callback;
    final AlertDialog.Builder builder = new AlertDialog.Builder(context);
    // Create the Web View to show the login page
    final WebView wv = new WebView(context);
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (externalCallback != null) {
                externalCallback.onCompleted(null, new MobileServiceException("User Canceled"));
            }
        }
    });
    wv.getSettings().setJavaScriptEnabled(true);

    DisplayMetrics displaymetrics = new DisplayMetrics();
    ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int webViewHeight = displaymetrics.heightPixels;

    wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight));

    wv.requestFocus(View.FOCUS_DOWN);
    wv.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View view, MotionEvent event) {
            int action = event.getAction();
            if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
                if (!view.hasFocus()) {
                    view.requestFocus();
                }
            }

            return false;
        }
    });

    // Create a LinearLayout and add the WebView to the Layout
    LinearLayout layout = new LinearLayout(context);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.addView(wv);

    // Add a dummy EditText to the layout as a workaround for a bug
    // that prevents showing the keyboard for the WebView on some devices
    EditText dummyEditText = new EditText(context);
    dummyEditText.setVisibility(View.GONE);
    layout.addView(dummyEditText);

    // Add the layout to the dialog
    builder.setView(layout);

    final AlertDialog dialog = builder.create();

    wv.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            // If the URL of the started page matches with the final URL
            // format, the login process finished
            if (isFinalUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(url, null);
                }

                dialog.dismiss();
            }

            super.onPageStarted(view, url, favicon);
        }

        // Checks if the given URL matches with the final URL's format
        private boolean isFinalUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(endUrl);
        }

        // Checks if the given URL matches with the start URL's format
        private boolean isStartUrl(String url) {
            if (url == null) {
                return false;
            }

            return url.startsWith(startUrl);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (isStartUrl(url)) {
                if (externalCallback != null) {
                    externalCallback.onCompleted(null, new MobileServiceException(
                            "Logging in with the selected authentication provider is not enabled"));
                }

                dialog.dismiss();
            }
        }
    });

    wv.loadUrl(startUrl);
    dialog.show();
}

From source file:com.ezac.gliderlogs.FlightOverviewActivity.java

public void DoFlightMember() {
    // get member_list.xml view
    LayoutInflater li = LayoutInflater.from(context);
    membersView = li.inflate(R.layout.member_list, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
    // set member_list.xml to alertdialog builder
    alertDialogBuilder.setView(membersView);
    ////  www  .j  a  v a2 s. c o  m
    Button mMember_Btn;
    final EditText mDetailInfo;
    Button mGlider_Btn;
    // set dialog message
    alertDialogBuilder.setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (!fPilo.equals("") && !fRegi.equals("")) {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = fRegiPilo + ":" + MemberIndexList.get(i);
                    }
                }
                DoFlightFilter(7, fRegiPilo);
                OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                        R.id.action_45min);
            } else if (!fRegi.equals("")) {
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        // set filter criteria for selected member
                        DoFlightFilter(6, GliderList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            } else if (!fPilo.equals("")) {
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        // set filter criteria for selected member
                        DoFlightFilter(5, MemberIndexList.get(i));
                        OptionSelect(R.id.action_my, R.id.action_all, R.id.action_open, R.id.action_ready,
                                R.id.action_45min);
                    }
                }
            }
        }
    }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            DoFlightFilter(4, "");
            OptionSelect(R.id.action_all, R.id.action_my, R.id.action_open, R.id.action_ready,
                    R.id.action_45min);
            dialog.cancel();
        }
    });
    AlertDialog alertDialog = alertDialogBuilder.create();
    // get reference to and fill spinner with members
    mMemberSpin = (Spinner) membersView.findViewById(R.id.flight_member);
    ArrayAdapter<String> dataAdapter_1 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, MemberList);
    dataAdapter_1.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mMemberSpin.setAdapter(dataAdapter_1);
    // get reference to and fill spinner with gliders
    mGliderSpin = (Spinner) membersView.findViewById(R.id.flight_glider);
    ArrayAdapter<String> dataAdapter_2 = new ArrayAdapter<String>(FlightOverviewActivity.this,
            android.R.layout.simple_spinner_item, GliderList);
    dataAdapter_2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mGliderSpin.setAdapter(dataAdapter_2);
    mDetailInfo = (EditText) membersView.findViewById(R.id.editText1);
    // make field read only
    mDetailInfo.setClickable(false);
    mDetailInfo.setFocusable(false);
    mGlider_Btn = (Button) membersView.findViewById(R.id.flight_glider_detail);
    mGlider_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fRegi = (String) mGliderSpin.getSelectedItem();
            if (fRegi.equals(null) || fRegi.equals("")) {
                mDetailInfo.setText("Geen Registratie selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mGliderSpin.getCount(); i++) {
                    String s = (String) mGliderSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fRegi)) {
                        fRegiPilo = GliderList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_GLIDER, fRegiPilo, 0));
            }
        }
    });
    mMember_Btn = (Button) membersView.findViewById(R.id.flight_member_detail);
    mMember_Btn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            String fPilo = (String) mMemberSpin.getSelectedItem();
            if (fPilo.equals(null) || fPilo.equals("")) {
                mDetailInfo.setText("Geen Naam selectie gevonden,\nmaak een keuze !");
            } else {
                String fRegiPilo = "";
                for (int i = 0; i < mMemberSpin.getCount(); i++) {
                    String s = (String) mMemberSpin.getItemAtPosition(i);
                    if (s.equalsIgnoreCase(fPilo)) {
                        fRegiPilo = MemberIndexList.get(i);
                    }
                }
                mDetailInfo.setText(getDetailInfo(FlightsContentProvider.CONTENT_URI_MEMBER, fRegiPilo, 1));
            }
        }
    });
    alertDialog.show();
}