Example usage for android.app AlertDialog setTitle

List of usage examples for android.app AlertDialog setTitle

Introduction

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

Prototype

@Override
    public void setTitle(CharSequence title) 

Source Link

Usage

From source file:com.tweetlanes.android.view.BaseLaneActivity.java

public void shareSelected(TwitterStatus status) {

    if (status != null) {

        final String statusUrl = status.getTwitterComStatusUrl();
        final String statusText = status.mStatus;
        final ArrayList<String> urls = Util.getUrlsInString(status.mStatus);

        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.alert_share_title));
        alertDialog.setMessage(getString(R.string.alert_share_message));
        alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark
                ? R.drawable.ic_action_share_dark
                : R.drawable.ic_action_share_light);
        // TODO: The order these buttons are set looks wrong, but appears correctly. Have to ensure this is consistent on other devices.
        alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                shareText(statusUrl);/*from w  w w.j  a  v  a 2  s .c o m*/
            }
        });

        if (urls != null && urls.size() > 0) {
            alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    shareText(statusText);
                }
            });

            alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            shareText(urls.get(0));
                        }
                    });
        } else {
            alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    shareText(statusText);
                }
            });
        }

        alertDialog.show();
    }
}

From source file:fr.android.scaron.diaspdroid.vues.fragment.ParamsFragment.java

@UiThread
public void showResultLogin(boolean loginOK) {
    String methodName = ".showResultLogin : ";
    LOG.d(methodName + "Entre");
    if (loginOK) {
        final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                DiasporaConfig.APPLICATION_CONTEXT);
        final AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
            @Override// w  w  w  .ja  v  a2s .  c  o  m
            public void onClick(final DialogInterface dialog, final int which) {
                String methodName = ".showResultLogin/loginOK/onClick : ";
                LOG.d(methodName + "Entre");
                DiasporaConfig.ParamsOK = true;
                DiasporaConfig.DB.putBoolean("configOK", true);
                LOG.d(methodName + "Params to true");

                LOG.d(methodName + "main activity type is " + activity.getClass().getName());
                if (activity instanceof MainActivity_) {
                    LOG.d(methodName + "call set defaultView on MainActivity_");
                    ((MainActivity_) activity).setDefaultView();
                } else if (activity instanceof MainActivity) {
                    LOG.d(methodName + "call set defaultView on MainActivity");
                    ((MainActivity) activity).setDefaultView();
                }
                alertDialog.dismiss();
            }
        });
        alertDialog.setIcon(R.drawable.ic_launcher);
        alertDialog.setTitle("Connexion russie");
        alertDialog.setMessage("Vos paramtres sont correctes.\nBon surf sur Diaspora !");
        alertDialog.show();
        LOG.d(methodName + "Sortie");
        return;
    }
    final AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(DiasporaConfig.APPLICATION_CONTEXT);
    final AlertDialog alertDialog = alertDialogBuilder.create();
    alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(final DialogInterface dialog, final int which) {
            String methodName = ".showResultLogin/loginKO/onClick : ";
            LOG.d(methodName + "Entre");
            DiasporaConfig.ParamsOK = false;
            DiasporaConfig.DB.putBoolean("configOK", false);
            LOG.d(methodName + "Params to false");
            alertDialog.dismiss();
        }
    });
    alertDialog.setIcon(R.drawable.ic_launcher);
    alertDialog.setTitle("PB Connexion");
    alertDialog.setMessage("La connexion a Diaspora a choue");
    alertDialog.show();
    LOG.d(methodName + "Sortie en erreur");
}

From source file:com.tweetlanes.android.core.view.BaseLaneActivity.java

public void shareSelected(TwitterStatus status) {

    if (status != null) {

        App application = (App) getApplication();
        AccountDescriptor currentAccount = application.getCurrentAccount();

        String url;/*from  w  ww .  j a v  a  2  s .co  m*/
        String shareText;
        if (currentAccount.getSocialNetType() == SocialNetConstant.Type.Twitter) {
            url = status.getTwitterComStatusUrl();
            shareText = getString(R.string.share_tweet_link);
        } else {
            url = status.getAdnStatusUrl();
            shareText = getString(R.string.share_tweet_post);
        }
        final String statusUrl = url;
        final String statusText = status.mStatus;
        final ArrayList<String> urls = Util.getUrlsInString(status.mStatus);

        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.alert_share_title));
        alertDialog.setMessage(getString(R.string.alert_share_message));
        alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark
                || AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Light_DarkAction
                        ? R.drawable.ic_action_share_dark
                        : R.drawable.ic_action_share_light);
        // TODO: The order these buttons are set looks wrong, but appears
        // correctly. Have to ensure this is consistent on other devices.
        alertDialog.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.share_tweet),
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        shareText(statusText);
                    }
                });

        alertDialog.setButton(DialogInterface.BUTTON_NEGATIVE, shareText,
                new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        shareText(statusUrl);
                    }
                });

        if (urls != null && urls.size() > 0) {
            alertDialog.setButton(DialogInterface.BUTTON_NEUTRAL,
                    getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link),
                    new DialogInterface.OnClickListener() {

                        public void onClick(DialogInterface dialog, int which) {
                            shareText(urls.get(0));
                        }
                    });
        }

        alertDialog.show();
    }
}

From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java

public void shareSelected(TwitterStatus status) {

    if (status != null) {

        final String statusUrl = status.getTwitterComStatusUrl();
        final String statusText = status.mStatus;
        final ArrayList<String> urls = Util.getUrlsInString(status.mStatus);

        AlertDialog alertDialog = new AlertDialog.Builder(this).create();
        alertDialog.setTitle(getString(R.string.alert_share_title));
        alertDialog.setMessage(getString(R.string.alert_share_message));
        alertDialog.setIcon(AppSettings.get().getCurrentTheme() == AppSettings.Theme.Holo_Dark
                ? R.drawable.ic_action_share_dark
                : R.drawable.ic_action_share_light);
        // TODO: The order these buttons are set looks wrong, but appears
        // correctly. Have to ensure this is consistent on other devices.
        alertDialog.setButton2(getString(R.string.share_tweet_link), new DialogInterface.OnClickListener() {

            @Override/*from w ww .  ja v a 2 s  . co  m*/
            public void onClick(DialogInterface dialog, int which) {
                shareText(statusUrl);
            }
        });

        if (urls != null && urls.size() > 0) {
            alertDialog.setButton3(getString(R.string.share_tweet), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    shareText(statusText);
                }
            });

            alertDialog.setButton(getString(urls.size() == 1 ? R.string.share_link : R.string.share_first_link),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            shareText(urls.get(0));
                        }
                    });
        } else {
            alertDialog.setButton(getString(R.string.share_tweet), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    shareText(statusText);
                }
            });
        }

        alertDialog.show();
    }
}

From source file:com.xperia64.rompatcher.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    staticThis = MainActivity.this;

    setContentView(R.layout.main);/*from  ww w.  ja  va2s  .c o  m*/
    // Load native libraries
    try {
        System.loadLibrary("apsn64patcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab apspatcher!");
    }
    try {
        System.loadLibrary("ipspatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ipspatcher!");
    }
    try {
        System.loadLibrary("ipspatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ipspatcher!");
    }
    try {
        System.loadLibrary("upspatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab upspatcher!");
    }
    try {
        System.loadLibrary("xdelta3patcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab xdelta3patcher!");
    }
    try {
        System.loadLibrary("bpspatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab bpspatcher!");
    }
    try {
        System.loadLibrary("bzip2");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab bzip2!");
    }
    try {
        System.loadLibrary("bsdiffpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab bsdiffpatcher!");
    }
    try {
        System.loadLibrary("ppfpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ppfpatcher!");
    }
    try {
        System.loadLibrary("ips32patcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ips32patcher!");
    }
    try {
        System.loadLibrary("glib-2.0");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab glib-2.0!");
    }
    try {
        System.loadLibrary("gmodule-2.0");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab gmodule-2.0!");
    }
    try {
        System.loadLibrary("edsio");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab edsio!");
    }
    try {
        System.loadLibrary("xdelta1patcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ips32patcher!");
    }
    try {
        System.loadLibrary("ips32patcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ips32patcher!");
    }
    try {
        System.loadLibrary("ecmpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab ecmpatcher!");
    }
    try {
        System.loadLibrary("dpspatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab dpspatcher!");
    }
    try {
        System.loadLibrary("dldipatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab dldipatcher!");
    }
    try {
        System.loadLibrary("xpcpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab xpcpatcher!");
    }
    try {
        System.loadLibrary("asarpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab asarpatcher!");
    }
    try {
        System.loadLibrary("asmpatcher");
    } catch (UnsatisfiedLinkError e) {
        Log.e("Bad:", "Cannot grab asmpatcher!");
    }
    c = (CheckBox) findViewById(R.id.backupCheckbox);
    d = (CheckBox) findViewById(R.id.altNameCheckbox);
    r = (CheckBox) findViewById(R.id.ignoreCRC);
    e = (CheckBox) findViewById(R.id.fileExtCheckbox);
    ed = (EditText) findViewById(R.id.txtOutFile);

    final Button romButton = (Button) findViewById(R.id.romButton);
    romButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Globals.mode = true;
            Intent intent = new Intent(staticThis, FileBrowserActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivityForResult(intent, 1);

        }
    });
    final Button patchButton = (Button) findViewById(R.id.patchButton);
    patchButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Globals.mode = false;
            Intent intent = new Intent(staticThis, FileBrowserActivity.class);
            intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivityForResult(intent, 1);
        }
    });
    final ImageButton bkHelp = (ImageButton) findViewById(R.id.backupHelp);
    bkHelp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(staticThis).create();
            dialog.setTitle(getResources().getString(R.string.bkup_rom));
            dialog.setMessage(getResources().getString(R.string.bkup_rom_desc));
            dialog.setCancelable(true);
            dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int buttonId) {

                        }
                    });
            dialog.show();
        }
    });
    final ImageButton altNameHelp = (ImageButton) findViewById(R.id.outfileHelp);
    altNameHelp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(staticThis).create();
            dialog.setTitle(getResources().getString(R.string.rename1));
            dialog.setMessage(getResources().getString(R.string.rename_desc));
            dialog.setCancelable(true);
            dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int buttonId) {

                        }
                    });
            dialog.show();
        }
    });
    final ImageButton chkHelp = (ImageButton) findViewById(R.id.ignoreHelp);
    chkHelp.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            AlertDialog dialog = new AlertDialog.Builder(staticThis).create();
            dialog.setTitle(getResources().getString(R.string.ignoreChks));
            dialog.setMessage(getResources().getString(R.string.ignoreChks_desc));
            dialog.setCancelable(true);
            dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int buttonId) {

                        }
                    });
            dialog.show();
        }
    });

    InputFilter filter = new InputFilter() {
        public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart,
                int dend) {
            for (int i = start; i < end; i++) {
                String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*";
                if (IC.contains("*" + source.charAt(i) + "*")) {
                    return "";
                }
            }
            return null;
        }
    };
    ed.setFilters(new InputFilter[] { filter });
    c.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (((CheckBox) v).isChecked()) {
                d.setEnabled(true);
                if (d.isChecked()) {
                    ed.setEnabled(true);
                    e.setEnabled(true);
                }
            } else {
                d.setEnabled(false);
                ed.setEnabled(false);
                e.setEnabled(false);
            }
        }
    });
    d.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (((CheckBox) v).isChecked()) {
                ed.setEnabled(true);
                e.setEnabled(true);
            } else {
                e.setEnabled(false);
                ed.setEnabled(false);
            }
        }
    });
    final Button applyButton = (Button) findViewById(R.id.applyPatch);
    applyButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            // Warn about patching archives.
            if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".7z")
                    || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".zip")
                    || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".rar")) {
                AlertDialog dialog = new AlertDialog.Builder(staticThis).create();
                dialog.setTitle(getResources().getString(R.string.warning));
                dialog.setMessage(getResources().getString(R.string.zip_warning_desc));
                dialog.setCancelable(false);
                dialog.setButton(DialogInterface.BUTTON_POSITIVE,
                        getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int buttonId) {

                                patchCheck();
                            }
                        });
                dialog.setButton(DialogInterface.BUTTON_NEGATIVE,
                        getResources().getString(android.R.string.cancel),
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int buttonId) {
                                Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch),
                                        Toast.LENGTH_SHORT);
                                t.show();

                            }
                        });
                dialog.show();
            } else {
                patchCheck();
            }

        }
    });
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        // Uggh.
        requestPermissions();
    }
}

From source file:ru.orangesoftware.financisto.activity.MainActivity.java

@Override
public boolean onNavigationItemSelected(MenuItem menuItem) {
    //Checking if the item is in checked state or not, if not make it in checked state
    if (menuItem.isCheckable()) {
        menuItem.setChecked(true);/*  www .j  av a  2 s .  c  om*/
    }

    //Closing drawer on item click
    mDrawerLayout.closeDrawers();

    if (menuItem.isChecked()) {
        ActionBar actionBar = getSupportActionBar();
        actionBar.setTitle(menuItem.getTitle());
        actionBar.setIcon(menuItem.getIcon());
    }

    FragmentManager fm = getSupportFragmentManager();

    navMenuItemId = menuItem.getItemId();
    //Check to see which item was being clicked and perform appropriate action
    switch (navMenuItemId) {

    //Replacing the main content with ContentFragment Which is our Inbox View;
    case R.id.accounts:
        selectedAccountId = -1;
        android.support.v4.app.FragmentTransaction fragmentTransaction = fm.beginTransaction();
        fragmentTransaction.replace(R.id.main_content_frame, AccountListFragment.newInstance(), "accounts");
        fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        fragmentTransaction.addToBackStack(null);
        fragmentTransaction.commit();

        fab.show();
        break;
    case R.id.blotter:
        android.support.v4.app.FragmentTransaction blotterFragmentTransaction = fm.beginTransaction();
        blotterFragmentTransaction.replace(R.id.main_content_frame,
                BlotterFragment.newInstance(true, selectedAccountId), "blotter");
        blotterFragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        blotterFragmentTransaction.addToBackStack(null);
        blotterFragmentTransaction.commit();

        fab.show();
        break;
    case R.id.scheduled_transactions:
        startActivity(new Intent(this, ScheduledListActivity.class));
        break;
    case R.id.budgets:
        android.support.v4.app.FragmentTransaction budgetFragmentTransaction = fm.beginTransaction();
        budgetFragmentTransaction.replace(R.id.main_content_frame, new BudgetListFragment());
        budgetFragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        budgetFragmentTransaction.addToBackStack(null);
        budgetFragmentTransaction.commit();

        fab.show();
        break;
    case R.id.reports:
        android.support.v4.app.FragmentTransaction reportsFragmentTransaction = fm.beginTransaction();
        reportsFragmentTransaction.replace(R.id.main_content_frame, new ReportListFragment());
        reportsFragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        reportsFragmentTransaction.addToBackStack(null);
        reportsFragmentTransaction.commit();

        fab.hide();
        break;
    case R.id.planner:
        startActivity(new Intent(this, PlannerActivity.class));
        break;
    case R.id.entities:
        final MenuEntities[] entities = MenuEntities.values();
        ListAdapter adapter = EnumUtils.createEntityEnumAdapter(this, entities);
        final AlertDialog d = new AlertDialog.Builder(this)
                .setAdapter(adapter, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        MenuEntities e = entities[which];
                        startActivity(new Intent(MainActivity.this, e.getActivityClass()));
                    }
                }).create();
        d.setTitle(R.string.entities);
        d.show();
        break;
    case R.id.menu_sync_online:
        doOnlineSync();
        break;
    //            case R.id.menu_sync_flowzr:
    //                doFlowzrSync();
    //                break;
    case R.id.menu_mass_operations:
        startActivity(new Intent(this, MassOpActivity.class));
        break;
    case R.id.menu_restore_database:
        doImport();
        break;
    case R.id.menu_backup_database:
        doBackup();
        break;
    case R.id.menu_backup_database_to:
        doBackupTo();
        break;
    case R.id.menu_backup_restore_database_online:
        showPickOneDialog(this, R.string.backup_restore_database_online, BackupRestoreEntities.values(), this);
        break;
    case R.id.menu_import_export:
        showPickOneDialog(this, R.string.import_export, ImportExportEntities.values(), this);
        break;
    case R.id.menu_settings:
        startActivityForResult(new Intent(this, PreferencesActivity.class), CHANGE_PREFERENCES_RESULT);
        break;
    case R.id.menu_integrity_fix:
        doIntegrityFix();
        break;
    case R.id.menu_donate:
        openBrowser("market://search?q=pname:ru.orangesoftware.financisto.support");
        break;
    case R.id.menu_about:
        startActivity(new Intent(this, AboutActivity.class));
        break;
    default:
        Toast.makeText(getApplicationContext(), "Somethings Wrong", Toast.LENGTH_SHORT).show();
        fab.hide();
        break;
    }

    fm.executePendingTransactions();
    return true;
}

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

/**
 * This function creates a dialog which gives a description of the symbols
 * that populate the map./*w w  w .j  ava 2s. 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 function creates a dialog which allows the user to register a item
 * or tool used.// w ww.j av  a 2  s.  c o m
 * 
 * @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:de.blinkt.openvpn.ActivityDashboard.java

public void handlerMessageBox(int id, Handler handler, String title, String message, String yes, String no,
        String cancel) {/*from www . j a  v  a 2 s  .  c om*/
    AlertDialog box = new AlertDialog.Builder(this).create();
    HandlerDialogClickListener listener = new HandlerDialogClickListener(handler, id);
    if (yes != null)
        box.setButton(AlertDialog.BUTTON_POSITIVE, yes, listener);
    if (no != null)
        box.setButton(AlertDialog.BUTTON_NEUTRAL, no, listener);
    if (cancel != null)
        box.setButton(AlertDialog.BUTTON_NEGATIVE, cancel, listener);
    box.setTitle(title);
    box.setMessage(message);
    box.show();
}