List of usage examples for android.app AlertDialog.Builder setView
public void setView(View view)
From source file:com.dimasdanz.kendalipintu.usermodel.UserDialogManager.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); final ArrayList<String> userData = new ArrayList<String>(); final View view = inflater.inflate(R.layout.dialog_user_form, null); final TextView txtUserID = (TextView) view.findViewById(R.id.txtUserID); final EditText txtUsername = (EditText) view.findViewById(R.id.txtUserName); final EditText txtUserPass = (EditText) view.findViewById(R.id.txtUserPass); int btnText = R.string.action_add_account; if (!getArguments().isEmpty()) { btnText = R.string.change;//from ww w. j av a 2 s.c o m txtUserID.setText(getArguments().getStringArrayList("data").get(0)); txtUsername.setText(getArguments().getStringArrayList("data").get(1)); txtUserPass.setText(getArguments().getStringArrayList("data").get(2)); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), 4); builder.setIcon(R.drawable.ic_action_group); builder.setTitle(R.string.dialog_title_userform); builder.setView(view); builder.setPositiveButton(btnText, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (txtUsername.getText().toString().length() > 0 || txtUserPass.getText().length() > 0) { userData.add(txtUserID.getText().toString()); userData.add(txtUsername.getText().toString()); userData.add(txtUserPass.getText().toString()); mListener.onDialogPositiveClick(UserDialogManager.this, userData); } else { //TODO Change string, use a better listener Toast.makeText(getActivity(), "Please fill all field", Toast.LENGTH_SHORT).show(); } } }); builder.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { if (txtUserID.getText().toString().length() > 0) { userData.add(txtUserID.getText().toString()); mListener.onDialogNegativeClick(UserDialogManager.this, userData); } else { //TODO Change string, use a better listener Toast.makeText(getActivity(), "Please fill all field", Toast.LENGTH_SHORT).show(); } } }); builder.setNeutralButton(R.string.close, null); return builder.create(); }
From source file:com.jdom.get.stuff.done.android.AndroidApplicationContextFactory.java
public void getTextInputForAction(String title, String hintText, String doButtonText, String dontButtonText, final RunnableWithResults<String> callback) { final EditText textView = new EditText(activity); textView.setHint(hintText);/*from w w w . j ava2 s.c o m*/ AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setView(textView); builder.setTitle(title); builder.setCancelable(false).setPositiveButton(doButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.callback(textView.getText().toString()); } }).setNegativeButton(dontButtonText, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { } }); builder.show(); }
From source file:com.cachirulop.moneybox.common.PromptDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder; _input = new EditText(getActivity()); builder = new AlertDialog.Builder(getActivity()); builder.setTitle(_titleId);/*from w ww .j av a 2s . c o m*/ builder.setMessage(_messageId); builder.setView(_input); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // Do nothing here because we // override this button later to // change the close behaviour. // However, we still need this // because on older versions of // Android unless we // pass a handler the button doesn't // get instantiated } }); builder.setNegativeButton(android.R.string.cancel, null); return builder.create(); }
From source file:com.example.androidlicensespage.LicensesFragment.java
@SuppressLint("InflateParams") @Override//from w ww. j a va2 s. c o m public Dialog onCreateDialog(Bundle savedInstanceState) { View content = LayoutInflater.from(getActivity()).inflate(R.layout.licenses_fragment, null); mWebView = (WebView) content.findViewById(R.id.licensesFragmentWebView); mIndeterminateProgress = (ProgressBar) content.findViewById(R.id.licensesFragmentIndeterminateProgress); boolean showCloseButton = false; Bundle arguments = getArguments(); if (arguments != null) { showCloseButton = arguments.getBoolean(KEY_SHOW_CLOSE_BUTTON); } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Open Source licenses"); builder.setView(content); if (showCloseButton) { builder.setNegativeButton("Close", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); } return builder.create(); }
From source file:com.Duo.music.player.Dialogs.CautionEditArtistsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*ww w. ja v a 2 s . co m*/ dialogFragment = this; EDIT_TYPE = this.getArguments().getString("EDIT_TYPE"); ARTIST = this.getArguments().getString("ARTIST"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_artists_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", EDIT_TYPE); bundle.putString("ARTIST", ARTIST); ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3ArtistEditorDialog"); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.CautionEditArtistsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/*from w w w . j a va 2s . c om*/ dialogFragment = this; EDIT_TYPE = this.getArguments().getString("EDIT_TYPE"); ARTIST = this.getArguments().getString("ARTIST"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_artists, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_artists_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ARTIST_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", EDIT_TYPE); bundle.putString("ARTIST", ARTIST); ID3sArtistEditorDialog dialog = new ID3sArtistEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3ArtistEditorDialog"); } }); return builder.create(); }
From source file:com.Duo.music.player.Dialogs.TrialExpiryDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();//w w w . j a va 2 s. c o m dialogFragment = this; View rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null); sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); //Check if the BETA version has expired. File file = new File(Environment.getExternalStorageDirectory() + "/.beta2"); if (file.exists()) { //The app has expired. EXPIRED_FLAG = true; } else { EXPIRED_FLAG = false; } /* //Change the dialog message based on the expiry status of the app. if (EXPIRED_FLAG==true) { trialExpiryText = (TextView) rootView.findViewById(R.id.beta_version_will_expire); trialExpiryText.setText(R.string.beta_has_expired); trialExpiryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); trialExpiryText.setPaintFlags(trialExpiryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); numberOfDaysLeftTextView = (TextView) rootView.findViewById(R.id.beta_expire_day_count); numberOfDaysLeftTextView.setVisibility(View.GONE); daysTextView = (TextView) rootView.findViewById(R.id.beta_days_text); daysTextView.setVisibility(View.GONE); trialCounterDummyInfoTextView = (TextView) rootView.findViewById(R.id.beta_trial_dummy_info_text); trialCounterDummyInfoTextView.setVisibility(View.GONE); } else { trialExpiryText = (TextView) rootView.findViewById(R.id.beta_version_will_expire); trialExpiryText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); trialExpiryText.setPaintFlags(trialExpiryText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); numberOfDaysLeftTextView = (TextView) rootView.findViewById(R.id.beta_expire_day_count); numberOfDaysLeftTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); numberOfDaysLeftTextView.setPaintFlags(numberOfDaysLeftTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); trialCounterDummyInfoTextView = (TextView) rootView.findViewById(R.id.beta_trial_dummy_info_text); trialCounterDummyInfoTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); trialCounterDummyInfoTextView.setPaintFlags(trialCounterDummyInfoTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); //Calculate the number of days left. Date date = new Date(); //1296000000 ms = 15 days. long expiryDate = sharedPreferences.getLong("EXPIRY_DATE", date.getTime() + 1296000000); long currentDate = date.getTime(); long millisLeft = expiryDate - currentDate; long daysLeft = TimeUnit.MILLISECONDS.toDays(millisLeft); numberOfDaysLeftTextView.setText("" + daysLeft); daysTextView = (TextView) rootView.findViewById(R.id.beta_days_text); daysTextView.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); daysTextView.setPaintFlags(daysTextView.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); }*/ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.app_name); builder.setView(rootView); builder.setPositiveButton(R.string.ok, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); if (EXPIRED_FLAG == true) { getActivity().finish(); } } }); return builder.create(); }
From source file:com.Duo.music.player.Dialogs.CautionEditAlbumsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();/* ww w .ja va 2s .c o m*/ dialogFragment = this; album = this.getArguments().getString("ALBUM"); artist = this.getArguments().getString("ARTIST"); callingActivity = this.getArguments().getString("CALLING_FRAGMENT"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_albums, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_albums_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.jams.music.player", Context.MODE_PRIVATE); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", "ALBUM"); bundle.putString("ALBUM", album); bundle.putString("ARTIST", artist); bundle.putString("CALLING_FRAGMENT", callingActivity); ID3sAlbumEditorDialog dialog = new ID3sAlbumEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3EditorDialog"); } }); return builder.create(); }
From source file:com.aniruddhc.acemusic.player.Dialogs.CautionEditAlbumsDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { parentActivity = getActivity();// ww w .jav a2s . c o m dialogFragment = this; album = this.getArguments().getString("ALBUM"); artist = this.getArguments().getString("ARTIST"); callingActivity = this.getArguments().getString("CALLING_FRAGMENT"); rootView = (View) parentActivity.getLayoutInflater().inflate(R.layout.fragment_caution_edit_albums, null); cautionText = (TextView) rootView.findViewById(R.id.caution_text); cautionText.setText(R.string.caution_albums_text); cautionText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); cautionText.setPaintFlags(cautionText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); sharedPreferences = getActivity().getSharedPreferences("com.aniruddhc.acemusic.player", Context.MODE_PRIVATE); dontShowAgainText = (TextView) rootView.findViewById(R.id.dont_show_again_text); dontShowAgainText.setTypeface(TypefaceHelper.getTypeface(parentActivity, "RobotoCondensed-Light")); dontShowAgainText.setPaintFlags( dontShowAgainText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); dontShowAgainCheckbox = (CheckBox) rootView.findViewById(R.id.dont_show_again_checkbox); dontShowAgainCheckbox.setChecked(true); sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); dontShowAgainCheckbox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { if (isChecked == true) { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", false).commit(); } else { sharedPreferences.edit().putBoolean("SHOW_ALBUM_EDIT_CAUTION", true).commit(); } } }); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); //Set the dialog title. builder.setTitle(R.string.caution); builder.setView(rootView); builder.setNegativeButton(R.string.no, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); } }); builder.setPositiveButton(R.string.yes, new OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { dialogFragment.dismiss(); FragmentTransaction ft = getFragmentManager().beginTransaction(); Bundle bundle = new Bundle(); bundle.putString("EDIT_TYPE", "ALBUM"); bundle.putString("ALBUM", album); bundle.putString("ARTIST", artist); bundle.putString("CALLING_FRAGMENT", callingActivity); ID3sAlbumEditorDialog dialog = new ID3sAlbumEditorDialog(); dialog.setArguments(bundle); dialog.show(ft, "id3EditorDialog"); } }); return builder.create(); }
From source file:com.androzic.LocationInfo.java
@SuppressLint("InflateParams") @Override//ww w .j a va2s . com public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.information_name)); View view = getActivity().getLayoutInflater().inflate(R.layout.dlg_location_info, null); builder.setView(view); builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { LocationInfo.this.dismiss(); } }); updateLocationInfo(view); return builder.create(); }