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:no.barentswatch.fiskinfo.BaseActivity.java

/**
 * This function creates a dialog which allows the user to register a item
 * or tool used./*w  w  w  .  ja va  2  s.  c  om*/
 * 
 * @param activityContext
 *            The context of the current activity.
 */
public void registerItemAndToolUsed(Context activityContext) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.dialog_register_tool, (null));
    final AlertDialog builder = new AlertDialog.Builder(activityContext).create();
    builder.setTitle(R.string.register_tool_dialog_title);
    builder.setView(view);
    final EditText startingCoordinates = (EditText) view.findViewById(R.id.registerStartingCoordinatesOfTool);
    final EditText endCoordinates = (EditText) view.findViewById(R.id.registerEndCoordinatesOfTool);
    final TextView invalidInputFeedback = (TextView) view.findViewById(R.id.RegisterToolInvalidInputTextView);

    if (lastSetStartingPosition != null) {
        startingCoordinates.setText(lastSetStartingPosition);
    }
    if (lastSetEndPosition != null) {
        endCoordinates.setText(lastSetEndPosition);
    }

    final Spinner projectionSpinner = (Spinner) view.findViewById(R.id.projectionChangingSpinner);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.projections,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    projectionSpinner.setPrompt("Velg projeksjon");
    projectionSpinner.setAdapter(
            new NoDefaultSpinner(adapter, R.layout.spinner_layout_select_projection, activityContext));

    final Spinner itemSpinner = (Spinner) view.findViewById(R.id.registerMiscType);
    ArrayAdapter<CharSequence> itemAdapter = ArrayAdapter.createFromResource(this, R.array.tool_types,
            android.R.layout.simple_spinner_item);
    itemAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    itemSpinner.setPrompt("Velg redskapstype");
    itemSpinner.setAdapter(
            new NoDefaultSpinner(itemAdapter, R.layout.spinner_layout_choose_tool, activityContext));

    Button fetchToolStartingCoordinatesButton = (Button) view
            .findViewById(R.id.dialogFetchUserStartingCoordinates);
    Button fetchToolEndCoordinatesButton = (Button) view.findViewById(R.id.dialogFetchUserEndCoordinates);

    fetchToolStartingCoordinatesButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            setToolCoordinatesPosition(startingCoordinates);
        }
    });

    fetchToolEndCoordinatesButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            setToolCoordinatesPosition(endCoordinates);
        }
    });

    acceptButtonRegister(view, builder, startingCoordinates, endCoordinates, invalidInputFeedback,
            projectionSpinner, itemSpinner);

    Button cancelButton = (Button) view.findViewById(R.id.DialogCancelRegistration);
    cancelButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            builder.dismiss();
        }
    });

    builder.show();
}

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

/**
 * This function creates a dialog which gives a description of the symbols
 * that populate the map./*ww w .ja  v a 2  s .  c o m*/
 * 
 * @param ActivityContext
 *            The context of the current activity.
 */
public void displaySymbolExplanation(Context ActivityContext) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.symbol_explanation, (null));
    final AlertDialog builder = new AlertDialog.Builder(ActivityContext).create();
    builder.setTitle(R.string.map_symbol_explanation);
    builder.setCanceledOnTouchOutside(false);
    builder.setView(view);

    Button okButton = (Button) view.findViewById(R.id.symbolOkButton);
    okButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            builder.dismiss();
        }
    });

    builder.show();
}

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

/**
 * This functions creates a dialog which allows the user to export different
 * map layers./*from   w w w. java2s .com*/
 * 
 * @param ActivityContext
 *            The context of the current activity.
 * @return True if the export succeeded, false otherwise.
 */
public boolean exportMapLayerToUser(Context activityContext) {
    LayoutInflater layoutInflater = getLayoutInflater();
    View view = layoutInflater.inflate(R.layout.dialog_export_metadata, (null));

    Button downloadButton = (Button) view.findViewById(R.id.metadataDownloadButton);
    Button cancelButton = (Button) view.findViewById(R.id.cancel_button);

    final AlertDialog builder = new AlertDialog.Builder(activityContext).create();
    builder.setTitle(R.string.map_export_metadata_title);
    builder.setView(view);
    final AtomicReference<String> selectedHeader = new AtomicReference<String>();
    final AtomicReference<String> selectedFormat = new AtomicReference<String>();
    final ExpandableListView expListView = (ExpandableListView) view
            .findViewById(R.id.exportMetadataMapServices);
    final List<String> listDataHeader = new ArrayList<String>();
    final HashMap<String, List<String>> listDataChild = new HashMap<String, List<String>>();
    final Map<String, String> nameToApiNameResolver = new HashMap<String, String>();

    JSONArray availableSubscriptions = getSharedCacheOfAvailableSubscriptions();
    if (availableSubscriptions == null) {
        availableSubscriptions = authenticatedGetRequestToBarentswatchAPIService(
                getString(R.string.my_page_geo_data_service));
        setSharedCacheOfAvailableSubscriptions(availableSubscriptions);
    }

    for (int i = 0; i < availableSubscriptions.length(); i++) {
        try {
            JSONObject currentSub = availableSubscriptions.getJSONObject(i);
            nameToApiNameResolver.put(currentSub.getString("Name"), currentSub.getString("ApiName"));
            listDataHeader.add(currentSub.getString("Name"));
            List<String> availableDownloadFormatsOfCurrentLayer = new ArrayList<String>();
            JSONArray availableFormats = currentSub.getJSONArray("Formats");
            for (int j = 0; j < availableFormats.length(); j++) {
                availableDownloadFormatsOfCurrentLayer.add(availableFormats.getString(j));
            }
            listDataChild.put(listDataHeader.get(i), availableDownloadFormatsOfCurrentLayer);

            System.out
                    .println("item: " + currentSub.getString("Name") + ", " + currentSub.getString("ApiName"));
        } catch (JSONException e) {
            e.printStackTrace();
            Log.d("ExportMapLAyerToUser", "Invalid JSON returned from API CALL");
            return false;
        }
    }
    final ExpandableListAdapter listAdapter = new ExpandableListAdapter(activityContext, listDataHeader,
            listDataChild);
    expListView.setAdapter(listAdapter);

    // Listview on child click listener
    expListView.setOnChildClickListener(new OnChildClickListener() {

        @Override
        public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition,
                long id) {
            selectedHeader.set(nameToApiNameResolver.get(listDataHeader.get(groupPosition)));
            selectedHeader.set(listDataHeader.get(groupPosition));
            selectedFormat.set(listDataChild.get(listDataHeader.get(groupPosition)).get(childPosition));

            LinearLayout currentlySelected = (LinearLayout) parent.findViewWithTag("currentlySelectedRow");
            if (currentlySelected != null) {
                currentlySelected.getChildAt(0).setBackgroundColor(Color.WHITE);
                currentlySelected.setTag(null);
            }

            ((LinearLayout) v).getChildAt(0).setBackgroundColor(Color.rgb(214, 214, 214));
            v.setTag("currentlySelectedRow");

            return true;
        }
    });

    downloadButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            new DownloadMapLayerFromBarentswatchApiInBackground()
                    .execute(nameToApiNameResolver.get(selectedHeader.get()), selectedFormat.get());
            builder.dismiss();
        }
    });

    cancelButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            builder.dismiss();
        }
    });

    builder.setCanceledOnTouchOutside(false);
    builder.show();

    return true;
}

From source file:com.picogram.awesomeness.SettingsActivity.java

public boolean onPreferenceClick(final Preference preference) {
    if (preference.getKey().equals("statistics")) {
        //TODO//from ww w. j av  a2  s  .  com
        Crouton.makeText(this, "This is not yet implemented", Style.INFO).show();
        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle",
                "Tapes per Minute", "Times Played" };
        final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0;
        final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed };
        // TODO: Implement the preferences and what not.
        final LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        for (int i = 0; i != scores.length; ++i) {
            final LinearLayout sub = new LinearLayout(this);
            sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
            sub.setOrientation(LinearLayout.HORIZONTAL);
            TextView tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scoresTitles[i]);
            sub.addView(tv);
            tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scores[i] + "");
            sub.addView(tv);
            ll.addView(sub);
        }
        dialog.setView(ll);
        dialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(final DialogInterface dialog, final int which) {
                dialog.dismiss();
            }
        });
        dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        dialog.show();
        dialog.dismiss();

        return true;
    } else if (preference.getKey().equals("changelog")) {
        // Launch change log dialog
        final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);
        _ChangelogDialog.show();
    } else if (preference.getKey().equals("licenses")) {
        // Launch the licenses stuff.
        Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create();
        ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        ld.show();
    } else if (preference.getKey().equals("email")) {
        final String email = "warner.73+Picogram@wright.edu";
        final String subject = "Picogram - <SUBJECT>";
        final String message = "Picogram,\n\n<MESSAGE>";
        // Contact me.
        final Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, message);
        emailIntent.setType("message/rfc822");
        this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :"));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
    } else if (preference.getKey().equals("rateapp")) {
        // TODO fix this when we publish.
        this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram")));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
        final Editor editor = this.prefs.edit();
        editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true);
        editor.commit();
    } else if (preference.getKey().equals("logoutgoogle")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("logoutfacebook")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("resetusername")) {
        Util.getPreferences(this).edit().putString("username", "").commit();
        Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit();
    }
    return false;
}

From source file:com.romanenco.gitt.BrowserActivity.java

/**
 * When pull from origin there are several case.
 * 1. We are in TAG (detached head): will inform user to
 * checkout a branch first.//  w w w  .  j a va 2s  .com
 * 2. Authentication required: ask for password (no passwd save).
 * 3. Anonymous user: just poll.
 */
private void pullFromOrigin() {
    if (current.getUserName() == null) {
        //no authentication required
        current.setState(Repo.State.Busy);
        DAO dao = new DAO(BrowserActivity.this);
        dao.open(true);
        dao.update(current);
        dao.close();
        Intent pull = new Intent(this, GitService.class);
        pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
        pull.putExtra(GitService.REPO, current);
        startService(pull);
        Intent main = new Intent(this, MainActivity.class);
        main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(main);
    } else {
        String req = getString(R.string.passwd_request, current.getUserName());
        final EditText passwd = new EditText(this);
        passwd.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
        AlertDialog dlg = new AlertDialog.Builder(this).setMessage(req)
                .setPositiveButton(getString(android.R.string.ok), new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        String password = passwd.getText().toString();
                        if (TextUtils.isEmpty(password)) {
                            pullFromOrigin();
                        } else {
                            current.setState(Repo.State.Busy);
                            DAO dao = new DAO(BrowserActivity.this);
                            dao.open(true);
                            dao.update(current);
                            dao.close();
                            Intent pull = new Intent(BrowserActivity.this, GitService.class);
                            pull.putExtra(GitService.COMMAND, GitService.Command.Pull);
                            pull.putExtra(GitService.REPO, current);
                            pull.putExtra(GitService.AUTH_PASSWD, password);
                            startService(pull);
                            Intent main = new Intent(BrowserActivity.this, MainActivity.class);
                            main.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                            startActivity(main);
                        }
                    }
                }).setNegativeButton(getString(android.R.string.cancel), null).create();
        dlg.setCanceledOnTouchOutside(false);
        dlg.setView(passwd);
        dlg.show();
    }

}

From source file:se.frikod.payday.DailyBudgetFragment.java

public void editBudgetItem(final View v, final int currentIndex) {

    LayoutInflater inflater = activity.getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.daily_budget_edit_budget_item, null);

    AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
    builder.setTitle(getString(R.string.edit_budget_item_title));

    final BudgetItem budgetItem;
    final EditText titleView = (EditText) dialogView.findViewById(R.id.budget_item_title);
    final Spinner typeView = (Spinner) dialogView.findViewById(R.id.budget_item_type);
    final EditText amountView = (EditText) dialogView.findViewById(R.id.budget_item_amount);

    if (currentIndex == NEW_BUDGET_ITEM) {
        budgetItem = null;/*  www.j  ava2  s. co m*/
        builder.setTitle(getString(R.string.add_budget_item_dialog_title));
        builder.setPositiveButton(R.string.add_budget_item, null);
    } else {
        builder.setTitle(getString(R.string.edit_budget_item_title));

        budgetItem = budget.budgetItems.get(currentIndex);

        String title = budgetItem.title;
        BigDecimal amount = budgetItem.amount;
        int type;
        if (amount.signum() < 0) {
            type = 0;
            amount = amount.negate();
        } else {
            type = 1;
        }

        titleView.setText(title);
        typeView.setSelection(type);
        amountView.setText(amount.toString());

        builder.setNeutralButton(getString(R.string.delete_budget_item_yes),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        Vibrator vibrator = (Vibrator) activity.getSystemService(Context.VIBRATOR_SERVICE);
                        vibrator.vibrate(100);
                        budget.budgetItems.remove(currentIndex);
                        budget.saveBudgetItems();
                        updateBudgetItems();
                        dialog.dismiss();
                    }

                });
        builder.setPositiveButton(R.string.update_budget_item, null);
    }

    builder.setNegativeButton(getString(R.string.delete_budget_item_no), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    /* onClick listener for update needs to be setup like this to
       prevent closing dialog on error
     */

    final AlertDialog d = builder.create();
    d.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button b = d.getButton(AlertDialog.BUTTON_POSITIVE);
            assert b != null;
            b.setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View view) {
                    BigDecimal amount;
                    try {
                        amount = new BigDecimal(amountView.getText().toString());
                        if (typeView.getSelectedItemId() == 0)
                            amount = amount.negate();
                    } catch (NumberFormatException e) {

                        Toast.makeText(activity.getApplicationContext(),
                                getString(R.string.new_budget_item_no_amount_specified), Toast.LENGTH_SHORT)
                                .show();

                        return;
                    }

                    String title = titleView.getText().toString();

                    if (budgetItem != null) {
                        budgetItem.amount = amount;
                        budgetItem.title = title;
                    } else {
                        budget.budgetItems.add(new BudgetItem(title, amount));
                    }

                    budget.saveBudgetItems();
                    updateBudgetItems();
                    d.dismiss();
                }
            });
        }
    });

    d.setView(dialogView);
    d.show();
}

From source file:org.sigimera.app.android.MainActivity.java

/**
 * Shows the about dialog./*  ww  w .  ja v a 2s.  c om*/
 */
public final void showAboutDialog() {
    AlertDialog dialog = new AlertDialog.Builder(MainActivity.this).create();
    dialog.setTitle("About");
    dialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            dialog.cancel();
        }
    });

    WebView wv = new WebView(this);
    wv.setBackgroundColor(Color.BLACK);

    StringBuffer strbuffer = new StringBuffer();
    strbuffer.append("<small><font color='white'>");
    strbuffer.append("<h3 style='text-align: center'>" + this.getString(R.string.app_name) + "</h3>");

    strbuffer.append("<p>This is the official App of the Crises "
            + "Information Platform Sigimera. It provides " + "the following functionality:</p>");
    strbuffer.append("<ul>");
    strbuffer.append("<li>Get crises (natural disaster) information."
            + "Currently floods, earthquakes, cyclones " + "and volcanic erruptions.</li>");
    strbuffer.append("<li>Get crises alerts via push notifications.</li>");
    strbuffer.append("<li>Get new crises via push notifications.</li>");
    strbuffer.append("<li>Manage your App via " + "<a href='http://www.sigimera.org/mobile_devices'>"
            + "<span style='color: #00FFFF'>mobile device management" + "website </span></a>.");
    strbuffer.append("</ul>");
    strbuffer.append("<p>&copy; 2013 <a href='http://www.sigimera.com'>"
            + "<span style='color: #00FFFF'>Sigimera Ltd.</span></a>. " + "All rights reserved.</p>");

    wv.loadData(strbuffer.toString(), "text/html", "utf-8");

    dialog.setView(wv);
    dialog.show();
}

From source file:group.pals.android.lib.ui.filechooser.FragmentFiles.java

/**
 * Confirms user to create new directory.
 *///w  ww .j a  v a2  s  . c o  m
private void showNewDirectoryCreationDialog() {
    final AlertDialog dialog = Dlg.newAlertDlg(getActivity());

    View view = getLayoutInflater(null).inflate(R.layout.afc_simple_text_input_view, null);
    final EditText textFile = (EditText) view.findViewById(R.id.afc_text1);
    textFile.setHint(R.string.afc_hint_folder_name);
    textFile.setOnEditorActionListener(new TextView.OnEditorActionListener() {

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

    dialog.setView(view);
    dialog.setTitle(R.string.afc_cmd_new_folder);
    dialog.setIcon(android.R.drawable.ic_menu_add);
    dialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(android.R.string.ok),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    final String name = textFile.getText().toString().trim();
                    if (!FileUtils.isFilenameValid(name)) {
                        Dlg.toast(getActivity(), getString(R.string.afc_pmsg_filename_is_invalid, name),
                                Dlg.LENGTH_SHORT);
                        return;
                    }

                    new LoadingDialog<Void, Void, Uri>(getActivity(), false) {

                        @Override
                        protected Uri doInBackground(Void... params) {
                            return getActivity().getContentResolver().insert(
                                    BaseFile.genContentUriBase(getCurrentLocation().getAuthority()).buildUpon()
                                            .appendPath(getCurrentLocation().getLastPathSegment())
                                            .appendQueryParameter(BaseFile.PARAM_NAME, name)
                                            .appendQueryParameter(BaseFile.PARAM_FILE_TYPE,
                                                    Integer.toString(BaseFile.FILE_TYPE_DIRECTORY))
                                            .build(),
                                    null);
                        }// doInBackground()

                        @Override
                        protected void onPostExecute(Uri result) {
                            super.onPostExecute(result);

                            if (result != null) {
                                Dlg.toast(getActivity(), getString(R.string.afc_msg_done), Dlg.LENGTH_SHORT);
                            } else
                                Dlg.toast(getActivity(),
                                        getString(R.string.afc_pmsg_cannot_create_folder, name),
                                        Dlg.LENGTH_SHORT);
                        }// onPostExecute()

                    }.execute();
                }// onClick()
            });
    dialog.show();
    Ui.showSoftKeyboard(textFile, true);

    final Button buttonOk = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
    buttonOk.setEnabled(false);

    textFile.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            /*
             * Do nothing.
             */
        }// onTextChanged()

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            /*
             * Do nothing.
             */
        }// beforeTextChanged()

        @Override
        public void afterTextChanged(Editable s) {
            buttonOk.setEnabled(FileUtils.isFilenameValid(s.toString().trim()));
        }// afterTextChanged()
    });
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public static void UIAlertHtml(String title, String html, Activity activity) {

    AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(title);/* ww w  .  j a v  a  2  s .  c om*/
    WebView webview = new WebView(activity);
    webview.setBackgroundColor(Color.BLACK);
    webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8");
    alertDialog.setView(webview);
    alertDialog.setButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            return;
        }
    });
    alertDialog.show();
}

From source file:com.max2idea.android.limbo.main.LimboActivity.java

public static void UIAlertLicense(String title, String html, final Activity activity) {

    AlertDialog alertDialog;
    alertDialog = new AlertDialog.Builder(activity).create();
    alertDialog.setTitle(title);//  ww  w .ja v a  2s.  com
    WebView webview = new WebView(activity);
    webview.setBackgroundColor(Color.BLACK);
    webview.loadData("<font color=\"FFFFFF\">" + html + " </font>", "text/html", "UTF-8");
    alertDialog.setView(webview);

    alertDialog.setButton("I Acknowledge", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            if (isFirstLaunch()) {
                install();
                onHelp();
                onChangeLog();
            }
            setFirstLaunch();
            return;
        }
    });
    alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (isFirstLaunch()) {
                if (activity.getParent() != null) {
                    activity.getParent().finish();
                } else {
                    activity.finish();
                }
            }
        }
    });
    alertDialog.show();
}