Example usage for android.app Dialog setTitle

List of usage examples for android.app Dialog setTitle

Introduction

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

Prototype

public void setTitle(@StringRes int titleId) 

Source Link

Document

Set the title text for this dialog's window.

Usage

From source file:com.medisa.myspacecal.Range.java

@Override
public void onSideNavigationItemClick(int itemId) {
    switch (itemId) {
    case R.id.side_navigation_menu_calendario:
        range = 0;/*from  w w  w.j  a v  a2  s  .c o  m*/
        Intent i = new Intent(this, MainActivity.class);
        startActivity(i);
        break;
    case R.id.side_navigation_menu_date_range:
        // custom dialog
        final Dialog dialog = new Dialog(this);
        dialog.setContentView(R.layout.custom_range_date);
        dialog.setTitle("Data range");

        // set the custom dialog components - text, image and button
        final DatePicker dpStart = (DatePicker) dialog.findViewById(R.id.dpStart);
        final DatePicker dpEnd = (DatePicker) dialog.findViewById(R.id.dpEnd);
        Button btnSalva = (Button) dialog.findViewById(R.id.btnSalva);
        final CheckBox cbIntegralBox = (CheckBox) dialog.findViewById(R.id.cbIntegral);
        // if button is clicked, close the custom dialog
        btnSalva.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                dateStart = Funzioni.addZero(dpStart.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpStart.getMonth(), 2) + "-" + dpStart.getYear();
                dateEnd = Funzioni.addZero(dpEnd.getDayOfMonth(), 2) + "-"
                        + Funzioni.addZero(dpEnd.getMonth(), 2) + "-" + dpEnd.getYear();
                Log.e(dateStart, dateEnd);
                if (cbIntegralBox.isChecked()) {
                    //#########################JSON
                    AsyncHttpClient client = new AsyncHttpClient();
                    client.get("http://199.180.196.10/json/integral?startdate=" + dateStart + "&enddate="
                            + dateEnd, new AsyncHttpResponseHandler() {
                                @Override
                                public void onSuccess(String response) {
                                    Log.e("SCARICATO", response);
                                    JSONArray jObject;
                                    try {
                                        jObject = new JSONArray(response);
                                        for (int i = 0; i < jObject.length(); i++) {
                                            JSONArray menuObject = jObject.getJSONArray(i);
                                            String dataStart = menuObject.getString(0);
                                            String dataEnd = menuObject.getString(1);
                                            String raj2000 = menuObject.getString(2);
                                            String decj2000 = menuObject.getString(3);
                                            String target = menuObject.getString(4);
                                            Log.e("", dataStart + " " + dataEnd + " " + raj2000 + " " + decj2000
                                                    + " " + target);
                                            satellitiIntegral.add(new SatelliteIntegral(dataStart, dataEnd,
                                                    raj2000, decj2000, target));
                                        }
                                    } catch (JSONException e) {
                                        // TODO Auto-generated catch block
                                        e.printStackTrace();
                                    }
                                }
                            });
                }

                dialog.dismiss();
                //                   Intent mioIntent= new Intent(ctx, Range.class);
                //                   startActivity(mioIntent);
            }

        });
        dialog.show();
        break;
    //            case R.id.side_navigation_menu_item3:
    //                invokeActivity(getString(R.string.title3), R.drawable.ic_android3);
    //                break;
    //
    //            case R.id.side_navigation_menu_item4:
    //                invokeActivity(getString(R.string.title4), R.drawable.ic_android4);
    //                break;
    //
    //            case R.id.side_navigation_menu_item5:
    //                invokeActivity(getString(R.string.title5), R.drawable.ic_android5);
    //                break;

    default:
        return;
    }
}

From source file:transapps.gpxfitness.ui.MainActivity.java

public void profileAlertDialog() {
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.profile_dialog);
    dialog.setTitle("Please Enter Profile:");
    dialog.setCancelable(false);//from  w w  w .  j a v  a2 s . co  m

    Button ok_button = (Button) dialog.findViewById(R.id.button);
    ok_button.setText("Ok");
    final EditText username = (EditText) dialog.findViewById(R.id.username);
    final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft);
    final EditText height_in = (EditText) dialog.findViewById(R.id.height_in);
    final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs);
    final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs);
    final RadioButton male = (RadioButton) dialog.findViewById(R.id.male);
    final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs };
    ok_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String user_string = username.getText().toString();
            String height_ft_string = height_ft.getText().toString();
            String height_in_string = height_in.getText().toString();
            String weight_lbs_string = weight_lbs.getText().toString();
            String age_yrs_string = age_yrs.getText().toString();
            boolean are_any_empty = false;
            for (EditText e : et) {
                String str = e.getText().toString();
                if (str == null || str.length() == 0)
                    are_any_empty = true;
            }
            if (!are_any_empty) {
                int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string);
                String sex;
                if (male.isChecked())
                    sex = "male";
                else
                    sex = "female";
                ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex,
                        Integer.parseInt(age_yrs_string));
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}

From source file:org.tigase.mobile.muc.JoinMucDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Dialog dialog = new Dialog(getActivity());
    dialog.setCancelable(true);//from  w  w w  .j  a v  a  2  s.  co m
    dialog.setCanceledOnTouchOutside(true);

    dialog.setContentView(R.layout.join_room_dialog);
    dialog.setTitle(getString(R.string.aboutButton));

    ArrayList<String> accounts = new ArrayList<String>();
    for (Account account : AccountManager.get(getActivity()).getAccountsByType(Constants.ACCOUNT_TYPE)) {
        accounts.add(account.name);
    }

    final Spinner accountSelector = (Spinner) dialog.findViewById(R.id.muc_accountSelector);
    final Button joinButton = (Button) dialog.findViewById(R.id.muc_joinButton);
    final Button cancelButton = (Button) dialog.findViewById(R.id.muc_cancelButton);
    final TextView name = (TextView) dialog.findViewById(R.id.muc_name);
    final TextView roomName = (TextView) dialog.findViewById(R.id.muc_roomName);
    final TextView mucServer = (TextView) dialog.findViewById(R.id.muc_server);
    final TextView nickname = (TextView) dialog.findViewById(R.id.muc_nickname);
    final TextView password = (TextView) dialog.findViewById(R.id.muc_password);
    final CheckBox autojoin = (CheckBox) dialog.findViewById(R.id.muc_autojoin);

    ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item,
            accounts.toArray(new String[] {}));
    accountSelector.setAdapter(adapter);

    Bundle data = getArguments();
    final boolean editMode = data != null && data.containsKey("editMode") && data.getBoolean("editMode");
    final String id = data != null ? data.getString("id") : null;

    if (data != null) {
        accountSelector.setSelection(adapter.getPosition(data.getString("account")));

        name.setText(data.getString("name"));
        roomName.setText(data.getString("room"));
        mucServer.setText(data.getString("server"));
        nickname.setText(data.getString("nick"));
        password.setText(data.getString("password"));
        autojoin.setChecked(data.getBoolean("autojoin"));
    }

    if (!editMode) {
        name.setVisibility(View.GONE);
        autojoin.setVisibility(View.GONE);
    } else {
        joinButton.setText("Save");
    }

    cancelButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dialog.dismiss();

        }
    });
    joinButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            if (editMode) {

                BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString());
                final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext())
                        .getMultiJaxmpp().get(account);

                Bundle data = new Bundle();

                data.putString("id", id);
                data.putString("account", account.toString());
                data.putString("name", name.getText().toString());
                data.putString("room", roomName.getText().toString());
                data.putString("server", mucServer.getText().toString());
                data.putString("nick", nickname.getText().toString());
                data.putString("password", password.getText().toString());
                data.putBoolean("autojoin", autojoin.isChecked());

                ((BookmarksActivity) getActivity()).saveItem(data);

                dialog.dismiss();
                return;
            }

            BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString());
            final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext())
                    .getMultiJaxmpp().get(account);

            Runnable r = new Runnable() {

                @Override
                public void run() {
                    try {
                        Room room = jaxmpp.getModule(MucModule.class).join(
                                roomName.getEditableText().toString(), mucServer.getEditableText().toString(),
                                nickname.getEditableText().toString(), password.getEditableText().toString());
                        if (task != null)
                            task.execute(room);
                    } catch (Exception e) {
                        Log.w("MUC", "", e);
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            };
            (new Thread(r)).start();
            dialog.dismiss();
        }
    });

    return dialog;
}

From source file:com.example.dany.jjdraw.MainActivity.java

@Override
public void onClick(View view) {
    if (view.getId() == R.id.draw_btn) {
        final Dialog brushDialog = new Dialog(this);
        brushDialog.setTitle("Brush size");
        brushDialog.setContentView(R.layout.brush_chooser);
        ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
        smallBtn.setOnClickListener(new OnClickListener() {
            @Override// ww  w. jav  a2 s .  co m
            public void onClick(View v) {
                drawView.setBrushSize(smallBrush);
                drawView.setLastBrushSize(smallBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
        mediumBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setBrushSize(mediumBrush);
                drawView.setLastBrushSize(mediumBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
        largeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setBrushSize(largeBrush);
                drawView.setLastBrushSize(largeBrush);
                drawView.setErase(false);
                brushDialog.dismiss();
            }
        });

        brushDialog.show();
    } else if (view.getId() == R.id.erase_btn) {
        //switch to erase - choose size
        final Dialog brushDialog = new Dialog(this);
        brushDialog.setTitle("Eraser size");
        brushDialog.setContentView(R.layout.brush_chooser);

        ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush);
        smallBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(smallBrush);
                brushDialog.dismiss();
            }
        });
        ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush);
        mediumBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(mediumBrush);
                brushDialog.dismiss();
            }
        });
        ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush);
        largeBtn.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                drawView.setErase(true);
                drawView.setBrushSize(largeBrush);
                brushDialog.dismiss();
            }
        });
        brushDialog.show();
    }

    else if (view.getId() == R.id.new_btn) {
        //new button
        AlertDialog.Builder newDialog = new AlertDialog.Builder(this);
        newDialog.setTitle("New drawing");
        newDialog.setMessage("Start new drawing (you will lose the current drawing)?");
        newDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                drawView.startNew(null);
                dialog.dismiss();
            }
        });
        newDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        newDialog.show();
    }

    else if (view.getId() == R.id.save_btn) {
        //save drawing
        AlertDialog.Builder saveDialog = new AlertDialog.Builder(this);
        saveDialog.setTitle("Save drawing");
        saveDialog.setMessage("Save drawing to device Gallery?");
        saveDialog.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {

                //save drawing
                drawView.setDrawingCacheEnabled(true);
                String imgSaved = MediaStore.Images.Media.insertImage(MainActivity.this.getContentResolver(),
                        drawView.getDrawingCache(), UUID.randomUUID().toString() + ".png", "drawing");

                if (imgSaved != null) {
                    Toast savedToast = Toast.makeText(getApplicationContext(), "Drawing saved to Gallery!",
                            Toast.LENGTH_SHORT);
                    savedToast.show();
                } else {
                    for (int i = 0; i < 3; i++) { // tried to increase the duration
                        Toast unsavedToast = Toast.makeText(getApplicationContext(),
                                "Oops! Image could not be saved. "
                                        + "Explicit write permission to storage device may required."
                                        + "Check Settings->" + "Application Manager->" + "JJDraw->"
                                        + "Permissions.",
                                Toast.LENGTH_LONG);
                        unsavedToast.show();
                    }
                }

                drawView.destroyDrawingCache();
            }
        });
        saveDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        saveDialog.show();
    }

}

From source file:pulseanddecibels.jp.yamatenki.activity.SplashActivity.java

private void displayUserLicenseAgreement() {
    final Dialog dialog = new Dialog(SplashActivity.this);
    //        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_license_agreement);
    dialog.setTitle(getString(R.string.text_license_agreement_title));
    dialog.setCanceledOnTouchOutside(false);
    Drawable d = new ColorDrawable(ContextCompat.getColor(this, R.color.yama_brown));
    dialog.getWindow().setBackgroundDrawable(d);
    dialog.show();//from  w ww .  ja v a  2 s .c  o m
    licenseAgreementDialogOpen = true;
    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
        @Override
        public void onDismiss(DialogInterface dialog) {
            if (!agreeButtonPressed) {
                licenseAgreementDialogOpen = false;
                settings.setAgreedToLicense(false);
                if (!databaseTaskRunning) {
                    finish();
                }
            }
        }
    });
    dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            licenseAgreementDialogOpen = false;
            settings.setAgreedToLicense(false);
            if (!databaseTaskRunning) {
                finish();
            }
        }
    });

    final Button agreeButton = (Button) dialog.findViewById(R.id.agree_button);
    agreeButton.setEnabled(false);
    agreeButton.setAlpha(.5f);
    agreeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            settings.setAgreedToLicense(true);
            agreeButtonPressed = true;
            dialog.dismiss();
            if (!databaseTaskRunning) {
                startMainActivity();
            }
        }
    });

    final CheckBox agreementCheckbox = (CheckBox) dialog.findViewById(R.id.agreement_checkbox);
    agreementCheckbox.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            CheckBox checkbox = (CheckBox) v;
            if (checkbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });

    TextView agreementLabel = (TextView) dialog.findViewById(R.id.agreement_label);
    agreementLabel.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            agreementCheckbox.setChecked(!agreementCheckbox.isChecked());
            if (agreementCheckbox.isChecked()) {
                agreeButton.setAlpha(1.0f);
                agreeButton.setEnabled(true);
            } else {
                agreeButton.setAlpha(.5f);
                agreeButton.setEnabled(false);
            }
        }
    });
}

From source file:com.starwood.anglerslong.MainActivity.java

/*****************************************************************************************
 * Dialog to show fishing regulations/*from   w  w w  .j a v  a2s. c  o  m*/
 *****************************************************************************************/
private void displayDialog() {

    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.fishing_reg_dialog);
    dialog.setTitle("Select a State:");

    dialog.findViewById(R.id.sc_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(scUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ga_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(gaUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.fl_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(flUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.al_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(alUrl));
            startActivity(browserIntent);
        }
    });

    dialog.findViewById(R.id.ms_button).setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(msUrl));
            startActivity(browserIntent);
        }
    });

    dialog.setCanceledOnTouchOutside(true);
    dialog.show();
}

From source file:nu.firetech.android.pactrack.frontend.ParcelIdDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);

    dialog.setContentView(R.layout.parcel_id_dialog);
    dialog.setTitle(R.string.menu_add_parcel);

    mErrorDialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.id_error_title)
            .setIconAttribute(android.R.attr.alertDialogIcon).setMessage(R.string.id_error_message)
            .setNeutralButton(R.string.ok, new OnClickListener() {
                @Override/*from  w w w  . ja v  a 2 s.co m*/
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();

    mDbAdapter = new ParcelDbAdapter(getActivity()).open();

    mParcelText = (EditText) dialog.findViewById(R.id.parcelid);
    mParcelText.setKeyListener(new NumberKeyListener() {
        private char[] acceptedChars = null;

        @Override
        protected char[] getAcceptedChars() {
            if (acceptedChars == null) {
                acceptedChars = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C',
                        'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T',
                        'U', 'V', 'W', 'X', 'Y', 'Z' };
            }

            return acceptedChars;
        }

        @Override
        public int getInputType() {
            return InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS;
        }
    });
    mNameText = (EditText) dialog.findViewById(R.id.parcelname);

    ImageButton scanButton = (ImageButton) dialog.findViewById(R.id.barcode);
    scanButton.setOnClickListener(new ScanButtonListener());
    Button cancelButton = (Button) dialog.findViewById(R.id.cancel);
    cancelButton.setOnClickListener(new ClosingButtonListener());
    Button okButton = (Button) dialog.findViewById(R.id.ok);
    okButton.setOnClickListener(new OkListener());

    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_ROWID)) {
        mRowId = savedInstanceState.getLong(ParcelDbAdapter.KEY_ROWID);
    }

    boolean loadParcel = false;

    mParcelInitialText = "";
    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_PARCEL)) {
        mParcelInitialText = savedInstanceState.getString(ParcelDbAdapter.KEY_PARCEL);
    } else if (mRowId != null) {
        loadParcel = true;
        mParcelInitialText = getString(R.string.loading);
        mParcelText.setEnabled(false);
    }
    mParcelText.setText(mParcelInitialText);

    mNameInitialText = "";
    if (savedInstanceState != null && savedInstanceState.containsKey(ParcelDbAdapter.KEY_NAME)) {
        mNameInitialText = savedInstanceState.getString(ParcelDbAdapter.KEY_NAME);
    } else if (mRowId != null) {
        loadParcel = true;
        mNameInitialText = getString(R.string.loading);
        mNameText.setEnabled(false);
    }
    mNameText.setText(mNameInitialText);

    mFocusedView = null;
    if (savedInstanceState != null && savedInstanceState.containsKey(KEY_FOCUSED_FIELD)) {
        mFocusedView = dialog.findViewById(savedInstanceState.getInt(KEY_FOCUSED_FIELD));

        mInitialSelectionStart = mInitialSelectionEnd = 0;
        if (mFocusedView instanceof EditText && savedInstanceState.containsKey(KEY_SELECTION_START)
                && savedInstanceState.containsKey(KEY_SELECTION_END)) {
            mInitialSelectionStart = savedInstanceState.getInt(KEY_SELECTION_START);
            mInitialSelectionEnd = savedInstanceState.getInt(KEY_SELECTION_END);

            Selection.setSelection(((EditText) mFocusedView).getText(), mInitialSelectionStart,
                    mInitialSelectionEnd);
        }
        mFocusedView.requestFocus();
    }

    if (loadParcel) {
        getLoaderManager().initLoader(INITIAL_LOADER_ID, null, this);
    }

    return dialog;
}

From source file:com.iskrembilen.quasseldroid.gui.LoginActivity.java

@Override
protected void onPrepareDialog(int id, Dialog dialog) {
    switch (id) {
    case R.id.DIALOG_ADD_CORE:
        dialog.setTitle("Add new core");
        break;/*from w  ww  .ja  va  2  s.com*/
    case R.id.DIALOG_EDIT_CORE:
        dialog.setTitle("Edit core");
        Bundle res = dbHelper.getCore(core.getSelectedItemId());
        ((EditText) dialog.findViewById(R.id.dialog_name_field))
                .setText(res.getString(QuasselDbHelper.KEY_NAME));
        ((EditText) dialog.findViewById(R.id.dialog_address_field))
                .setText(res.getString(QuasselDbHelper.KEY_ADDRESS));
        ((EditText) dialog.findViewById(R.id.dialog_port_field))
                .setText(Integer.toString(res.getInt(QuasselDbHelper.KEY_PORT)));
        ((CheckBox) dialog.findViewById(R.id.dialog_usessl_checkbox))
                .setChecked(res.getBoolean(QuasselDbHelper.KEY_SSL));
        break;
    }

    super.onPrepareDialog(id, dialog);
}

From source file:transapps.gpxfitness.ui.MainActivity.java

public void editProfileAlertDialog() {
    if (!ProfileAccessor.isProfileSet()) {
        profileAlertDialog();// w  w w  . j a v  a  2  s  .  c  o  m
        return;
    }
    final Dialog dialog = new Dialog(this);
    dialog.setContentView(R.layout.profile_dialog);
    dialog.setTitle("Edit Profile:");
    dialog.setCancelable(true);

    Button ok_button = (Button) dialog.findViewById(R.id.button);
    ok_button.setText("Ok");
    final EditText username = (EditText) dialog.findViewById(R.id.username);
    username.setText(ProfileAccessor.getUsername());
    final EditText height_ft = (EditText) dialog.findViewById(R.id.height_ft);
    height_ft.setText("" + (int) ProfileAccessor.getHeight() / 12);
    final EditText height_in = (EditText) dialog.findViewById(R.id.height_in);
    height_in.setText("" + (int) ProfileAccessor.getHeight() % 12);
    final EditText weight_lbs = (EditText) dialog.findViewById(R.id.weight_lbs);
    weight_lbs.setText(ProfileAccessor.getWeight() + "");
    final EditText age_yrs = (EditText) dialog.findViewById(R.id.age_yrs);
    age_yrs.setText(ProfileAccessor.getAge() + "");
    final RadioButton male = (RadioButton) dialog.findViewById(R.id.male);
    final RadioButton female = (RadioButton) dialog.findViewById(R.id.female);
    if (ProfileAccessor.getSex().equals("male")) {
        male.setChecked(true);
        female.setChecked(false);
    } else {
        male.setChecked(false);
        female.setChecked(true);
    }
    final EditText[] et = { username, height_ft, height_in, weight_lbs, age_yrs };
    ok_button.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            String user_string = username.getText().toString();
            String height_ft_string = height_ft.getText().toString();
            String height_in_string = height_in.getText().toString();
            Log.d("TEXT", height_in_string);
            String weight_lbs_string = weight_lbs.getText().toString();
            String age_yrs_string = age_yrs.getText().toString();
            boolean are_any_empty = false;
            for (EditText e : et) {
                String str = e.getText().toString();
                if (str == null || str.length() == 0)
                    are_any_empty = true;
            }
            if (!are_any_empty) {
                int height = Integer.parseInt(height_ft_string) * 12 + Integer.parseInt(height_in_string);
                String sex;
                if (male.isChecked())
                    sex = "male";
                else
                    sex = "female";
                //ProfileAccessor.createNewProfile(user_string, height, Integer.parseInt(weight_lbs_string), sex, Integer.parseInt(age_yrs_string));
                ProfileAccessor.changeUsername(user_string);
                //actionBar.setTitle(getString(R.string.app_name) + ": " + ProfileAccessor.getUsername());
                ProfileAccessor.changeHeight(height);
                ProfileAccessor.changeWeight(Double.parseDouble(weight_lbs_string));
                ProfileAccessor.changeSex(sex);
                ProfileAccessor.changeAge(Integer.parseInt(age_yrs_string));
                dialog.dismiss();
            }
        }
    });

    dialog.show();
}

From source file:com.adithya321.sharesanalysis.fragments.SharePurchaseFragment.java

@Nullable
@Override//from   w ww  . j  a  v  a 2 s . co  m
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_share_purchase, container, false);

    databaseHandler = new DatabaseHandler(getContext());
    sharePurchasesRecyclerView = (RecyclerView) root.findViewById(R.id.share_purchases_recycler_view);
    emptyTV = (TextView) root.findViewById(R.id.empty);
    arrow = (ImageView) root.findViewById(R.id.arrow);
    setRecyclerViewAdapter();

    FloatingActionButton addPurchaseFab = (FloatingActionButton) root.findViewById(R.id.add_purchase_fab);
    addPurchaseFab.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Dialog dialog = new Dialog(getContext());
            dialog.setTitle("Add Share Purchase");
            dialog.setContentView(R.layout.dialog_add_share_purchase);
            dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT,
                    WindowManager.LayoutParams.WRAP_CONTENT);
            dialog.show();

            final AutoCompleteTextView name = (AutoCompleteTextView) dialog.findViewById(R.id.share_name);
            List<String> nseList = ShareUtils.getNseList(getContext());
            FilterWithSpaceAdapter<String> arrayAdapter = new FilterWithSpaceAdapter<>(getContext(),
                    android.R.layout.simple_dropdown_item_1line, nseList);
            name.setThreshold(1);
            name.setAdapter(arrayAdapter);

            final Spinner spinner = (Spinner) dialog.findViewById(R.id.existing_spinner);

            ArrayList<String> shares = new ArrayList<>();
            for (Share share : sharesList) {
                shares.add(share.getName());
            }
            ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(getContext(),
                    android.R.layout.simple_spinner_item, shares);
            spinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(spinnerAdapter);

            final RadioButton newRB = (RadioButton) dialog.findViewById(R.id.radioBtn_new);
            RadioButton existingRB = (RadioButton) dialog.findViewById(R.id.radioBtn_existing);
            if (shares.size() == 0)
                existingRB.setVisibility(View.GONE);
            (newRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.VISIBLE);
                    spinner.setVisibility(View.GONE);
                }
            });

            (existingRB).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    name.setVisibility(View.GONE);
                    spinner.setVisibility(View.VISIBLE);
                }
            });

            Calendar calendar = Calendar.getInstance();
            year_start = calendar.get(Calendar.YEAR);
            month_start = calendar.get(Calendar.MONTH) + 1;
            day_start = calendar.get(Calendar.DAY_OF_MONTH);
            final Button selectDate = (Button) dialog.findViewById(R.id.select_date);
            selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/")
                    .append(year_start));
            selectDate.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start,
                            month_start - 1, day_start);
                    dialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                        @Override
                        public void onDismiss(DialogInterface dialog) {
                            selectDate.setText(new StringBuilder().append(day_start).append("/")
                                    .append(month_start).append("/").append(year_start));
                        }
                    });
                    dialog.show();
                }
            });

            Button addPurchaseBtn = (Button) dialog.findViewById(R.id.add_purchase_btn);
            addPurchaseBtn.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Share share = new Share();
                    share.setId(databaseHandler.getNextKey("share"));
                    share.setPurchases(new RealmList<Purchase>());
                    Purchase purchase = new Purchase();
                    purchase.setId(databaseHandler.getNextKey("purchase"));

                    if (newRB.isChecked()) {
                        String sName = name.getText().toString().trim();
                        if (sName.equals("")) {
                            Toast.makeText(getActivity(), "Invalid Name", Toast.LENGTH_SHORT).show();
                            return;
                        } else {
                            share.setName(sName);
                            purchase.setName(sName);
                        }
                    }

                    String stringStartDate = year_start + " " + month_start + " " + day_start;
                    DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH);
                    try {
                        Date date = format.parse(stringStartDate);
                        share.setDateOfInitialPurchase(date);
                        purchase.setDate(date);
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText quantity = (EditText) dialog.findViewById(R.id.no_of_shares);
                    try {
                        purchase.setQuantity(Integer.parseInt(quantity.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Number of Shares", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    EditText price = (EditText) dialog.findViewById(R.id.buying_price);
                    try {
                        purchase.setPrice(Double.parseDouble(price.getText().toString()));
                    } catch (Exception e) {
                        Toast.makeText(getActivity(), "Invalid Buying Price", Toast.LENGTH_SHORT).show();
                        return;
                    }

                    purchase.setType("buy");
                    if (newRB.isChecked()) {
                        if (!databaseHandler.addShare(share, purchase)) {
                            Toast.makeText(getActivity(), "Share Already Exists", Toast.LENGTH_SHORT).show();
                            return;
                        }
                    } else {
                        purchase.setName(spinner.getSelectedItem().toString());
                        databaseHandler.addPurchase(spinner.getSelectedItem().toString(), purchase);
                    }
                    setRecyclerViewAdapter();
                    dialog.dismiss();
                }
            });
        }
    });

    return root;
}