Simplest yes/no dialog fragment

A DialogFragment is really just a fragment that wraps a dialog. You can put any kind of dialog in there by creating and returning the dialog in the onCreateDialog() method of the DialogFragment. Heres an example DialogFragment: class MyDialogFragment extends DialogFragment{ Context mContext; public MyDialogFragment() { mContext = getActivity(); } @Override public Dialog onCreateDialog(Bundle savedInstanceState) … Read more

How to resize AlertDialog on the Keyboard display

If your dialog was an activity using one of the Dialog themes you could effect this behavior by setting the adjustResize flag for the windowSoftInputMode parameter of the activity. I’m using: android:windowSoftInputMode=”adjustResize|stateHidden” I think you can still use this flag with regular dialogs, but I’m not sure how to apply it. You may have to … Read more

How to add an icon before each item in alert dialog?

You need custom ListAdapter to add your image. One way is to subclass the ArrayAdapter (used by default by the AlertDialog). Here is an example: final Item[] items = { new Item(“Email”, android.R.drawable.ic_menu_add), new Item(“Facebook”, android.R.drawable.ic_menu_delete), new Item(“…”, 0),//no icon for this one }; ListAdapter adapter = new ArrayAdapter<Item>( this, android.R.layout.select_dialog_item, android.R.id.text1, items){ public View … Read more

Alert Dialog Two Buttons

Adding Buttons AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(“Are you sure you want to exit?”) .setCancelable(false) .setPositiveButton(“Yes”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { MyActivity.this.finish(); } }) .setNegativeButton(“No”, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog alert = builder.create(); alert.show();

Changing font size into an AlertDialog

You can actually get access to the message’s TextView pretty easily, and then change it’s size. I tested with a bigger size, but you could use whatever size you want. The text will scroll nicely as it already does. The view’s id is android.R.id.message AlertDialog dialog = new AlertDialog.Builder(this).setMessage(“Hello world”).show(); TextView textView = (TextView) dialog.findViewById(android.R.id.message); … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)