Example usage for android.app Dialog setContentView

List of usage examples for android.app Dialog setContentView

Introduction

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

Prototype

public void setContentView(@NonNull View view) 

Source Link

Document

Set the screen content to an explicit view.

Usage

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 ww  .  j  ava  2  s .c o  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: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  ww  w . j ava 2  s  .  c  om*/

    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:com.starwood.anglerslong.MainActivity.java

/*****************************************************************************************
 * Dialog to show fishing regulations//  w  ww .j ava  2 s .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:com.yammy.meter.MainActivity.java

private void showAlert() {
    final Dialog myDialog = new Dialog(this);
    myDialog.setContentView(R.layout.isvo_dialog_low_oil);
    myDialog.setCancelable(true);/* www  .j  av a 2  s .c o  m*/
    myDialog.setTitle("Peringatan!");
    Button batal = (Button) myDialog.findViewById(R.id.dialog_low_oil_cancel);
    Button cari = (Button) myDialog.findViewById(R.id.dialog_low_oil_cari);
    myDialog.show();
    cari.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(MainActivity.this, MainCari.class);
            startActivity(i);
        }
    });
    batal.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            myDialog.cancel();
        }
    });
}

From source file:com.sssemil.advancedsettings.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    new Thread(new Runnable() {
        @Override/*from   www  . j  av a 2  s.co m*/
        public void run() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
                while (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this,
                            new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST);

                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                while (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this,
                            new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST);

                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                while (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.WRITE_SETTINGS) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this,
                            new String[] { Manifest.permission.WRITE_SETTINGS }, REQUEST);

                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                while (ContextCompat.checkSelfPermission(MainActivity.this,
                        Manifest.permission.SYSTEM_ALERT_WINDOW) != PackageManager.PERMISSION_GRANTED) {
                    ActivityCompat.requestPermissions(MainActivity.this,
                            new String[] { Manifest.permission.SYSTEM_ALERT_WINDOW }, REQUEST);

                    try {
                        Thread.sleep(5000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }

                /*if (!android.provider.Settings.System.canWrite(MainActivity.this)) {
                mContinue = false;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        mAlertDialog = new AlertDialog.Builder(MainActivity.this)
                                .setMessage(getString(R.string.grant_access_settings))
                                .setPositiveButton(getString(android.R.string.ok),
                                        new DialogInterface.OnClickListener() {
                                            @Override
                                            public void onClick(DialogInterface dialog, int which) {
                                                mContinue = true;
                                            }
                                        })
                                .create();
                        mAlertDialog.show();
                    }
                });
                        
                while (!mContinue) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                        
                Intent intent = new Intent();
                intent.setAction(android.provider.Settings.ACTION_MANAGE_WRITE_SETTINGS);
                intent.setData(Uri.parse("package:" + getPackageName()));
                        
                // Start Activity
                startActivityForResult(intent, REQUEST);
                        
                while (!mContinueActivity) {
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                }*/
            }
        }
    }).start();

    SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    sharedPreferences.edit().putString("system_language", Locale.getDefault().getLanguage().toLowerCase() + "-"
            + Locale.getDefault().getCountry().toUpperCase()).apply();

    sharedPreferences.registerOnSharedPreferenceChangeListener(this);

    final View prefsRoot = inflater.inflate(R.layout.preferences, null);

    final List<Preference> loadedPreferences = new ArrayList<>();
    for (int i = 0; i < ((PreferenceScreen) prefsRoot).getChildCount(); i++) {
        if ((parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)).getKey()).equals("wifi_settings")) {
            if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_WIFI)) {
                loadedPreferences.add(parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)));
            }
        } else if ((parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)).getKey())
                .equals("bluetooth_setting")) {
            if (getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH)) {
                loadedPreferences.add(parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)));
            }
        } else if ((parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)).getKey())
                .equals("power_settings")) {
            loadedPreferences.add(parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)));
        } else if ((parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)).getKey())
                .equals("system_language")) {
            if (Utils.isPackageInstalled("sssemil.com.languagesettingsprovider", this, 1)) {
                loadedPreferences.add(parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)));
            }
        } else {
            loadedPreferences.add(parsePreference(((PreferenceScreen) prefsRoot).getChildAt(i)));
        }
    }
    addPreferences(loadedPreferences);

    this.startService(new Intent(this, MainService.class));

    if (!Utils.isDeviceRooted()) {
        Dialog dialog = new Dialog(this);
        dialog.setTitle("Warning");
        dialog.setContentView(R.layout.warning);
        dialog.show();
    }
}

From source file:com.untie.daywal.activity.MainActivity.java

private void showDayPicker() {

    Calendar calender = Calendar.getInstance();
    pickedYear = calender.get(Calendar.YEAR);
    pickedMonth = calender.get(Calendar.MONTH) + 1;
    final Dialog dayPickerDialog = new Dialog(this);
    dayPickerDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dayPickerDialog.setContentView(R.layout.dialog);
    Button okBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_ok);
    Button cancelBtn = (Button) dayPickerDialog.findViewById(R.id.birthday_btn_cancel);
    dialog_year_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_year_title);
    dialog_month_title = (TextView) dayPickerDialog.findViewById(R.id.dialog_month_title);
    final NumberPicker yearPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.yearPicker);
    final NumberPicker monthPicker = (NumberPicker) dayPickerDialog.findViewById(R.id.monthPicker);

    dialog_year_title.setText(String.valueOf(pickedYear) + "");
    dialog_month_title.setText(String.valueOf(pickedMonth) + "");
    yearPicker.setMinValue(pickedYear - 100);
    yearPicker.setMaxValue(pickedYear + 40);
    yearPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    //   setDividerColor(yearPicker, android.R.color.white );
    yearPicker.setWrapSelectorWheel(false);
    yearPicker.setValue(pickedYear);//from   w ww  .j  a v  a  2  s .c  o m
    yearPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            dialog_year_title.setText(String.valueOf(newVal) + "");
        }
    });

    monthPicker.setMinValue(1);
    monthPicker.setMaxValue(12);
    monthPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
    //   setDividerColor(monthPicker, android.R.color.white);
    //monthPicker.setWrapSelectorWheel(false);
    monthPicker.setValue(pickedMonth);
    monthPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
        @Override
        public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
            dialog_month_title.setText(String.valueOf(newVal) + "");
        }
    });

    okBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            //TODO :  ?? yearPicker.getValue() monthPicker.getValue()

            //Toast.makeText(MainActivity.this, String.valueOf(yearPicker.getValue())+"/"+monthPicker.getValue(), Toast.LENGTH_SHORT).show();

            Intent intent = new Intent(MainActivity.this, MainActivity.class);
            intent.putExtra("year", yearPicker.getValue());
            intent.putExtra("month", monthPicker.getValue());
            intent.putExtra("order", 1);
            dayPickerDialog.dismiss();
            startActivity(intent);
            overridePendingTransition(0, 0);

        }
    });
    cancelBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dayPickerDialog.dismiss();
        }
    });
    dayPickerDialog.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  ww  .j  a  v  a2  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:transapps.gpxfitness.ui.MainActivity.java

public void editProfileAlertDialog() {
    if (!ProfileAccessor.isProfileSet()) {
        profileAlertDialog();/*from   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.angelhack.person2person.AbstractGetNameTask.java

@Override
protected void onPostExecute(Void result) {
    // TODO Auto-generated method stub
    super.onPostExecute(result);

    try {/* w w  w .j a  v  a 2s.  co  m*/
        System.out.println("On Home Page***" + AbstractGetNameTask.GOOGLE_USER_DATA);
        JSONObject profileData = new JSONObject(AbstractGetNameTask.GOOGLE_USER_DATA);

        if (profileData.has("picture")) {
            SocialMedia_New.userImageUrl = profileData.getString("picture");

        }
        if (profileData.has("name")) {
            SocialMedia_New.textName = profileData.getString("name");
            //      SocialMedia_New.textViewName.setText(SocialMedia_New.textName);
        }

        dialog.dismiss();

        final Dialog alert_dialog = new Dialog(mActivity);
        alert_dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        alert_dialog.setContentView(R.layout.dialog_custom);

        TextView content = (TextView) alert_dialog.findViewById(R.id.content_tv_id);
        TextView ok = (TextView) alert_dialog.findViewById(R.id.ok_tv_id);
        profile = (ImageView) alert_dialog.findViewById(R.id.image_id);

        new GetImageFromUrl().execute(SocialMedia_New.userImageUrl);

        content.setText(" Welcome  " + SocialMedia_New.textName);
        ok.setText("Stay Connect with Us..!");

        ok.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub

                Intent intent = new Intent(mActivity, Home_Activity.class);
                mActivity.startActivity(intent);

                mActivity.overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);

                mActivity.finish();

            }
        });

        alert_dialog.show();

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:org.feedhenry.blank.MainActivity.java

private void createDialog(String action, final Item item) {
    final Dialog newDialog = new Dialog(this);
    newDialog.setContentView(R.layout.dialog);
    // Edit text//from  w  w  w  .  j a v a2s .  c  om
    final EditText userInput = (EditText) newDialog.findViewById(R.id.newitemtext);
    TextView title = (TextView) newDialog.findViewById(R.id.title);
    ///OK Button
    Button okDialogButton = (Button) newDialog.findViewById(R.id.okbutton);
    // Cancel Button
    Button cancelDialogButton = (Button) newDialog.findViewById(R.id.cancelbutton);
    cancelDialogButton.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

            newDialog.dismiss();
        }
    });

    if (action.matches("newitem")) {
        //newDialog.setTitle("Enter New Name");
        title.setText("Enter New Name");
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    sendNewItemToCloud(userInput.getText().toString());
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    } else if (action.matches("updateitem")) {
        title.setText("Update Name");
        userInput.setText(item.getName());
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    updateItemToCloud(userInput.getText().toString(), item);
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    } else if (action.matches("deleteitem")) {
        title.setText("Delete Name");
        userInput.setText(item.getName());
        userInput.setFocusable(false);
        okDialogButton.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                if (userInput.getText().length() > 0) {
                    deleteItemFromCloud(userInput.getText().toString(), item);
                    userInput.setText("");
                }
                newDialog.dismiss();
            }
        });
        newDialog.show();
    }
}