How to set DialogFragment’s width and height?

If you convert directly from resources values: int width = getResources().getDimensionPixelSize(R.dimen.popup_width); int height = getResources().getDimensionPixelSize(R.dimen.popup_height); getDialog().getWindow().setLayout(width, height); Then specify match_parent in your layout for the dialog: android:layout_width=”match_parent” android:layout_height=”match_parent” Now you only have to worry about one place (i.e. your DialogFragment.onResume method). It’s not perfect but at least it works for having a RelativeLayout as the … Read more

Android DialogFragment vs Dialog

Yes, use DialogFragment and in onCreateDialog you can simply use an AlertDialog builder anyway to create a simple AlertDialog with Yes/No confirmation buttons. Not very much code at all. With regards handling events in your fragment there would be various ways of doing it but I simply define a message Handler in my Fragment, pass … Read more

How to create a DialogFragment without title?

Just add this line of code in your HelpDialog.onCreateView(…) getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); This way you’re explicitly asking to get a window without title 🙂 EDIT As @DataGraham and @Blundell pointed out on the comments below, it’s safer to add the request for a title-less window in the onCreateDialog() method instead of onCreateView(). This way you can prevent … Read more

How to create a Custom Dialog box in android?

Here I have created a simple Dialog, like: custom_dialog.xml <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”80dp” android:background=”#3E80B4″ android:orientation=”vertical” > <TextView android:id=”@+id/txt_dia” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” android:layout_margin=”10dp” android:text=”Do you realy want to exit ?” android:textColor=”@android:color/white” android:textSize=”15dp” android:textStyle=”bold”/> <LinearLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”center” android:background=”#3E80B4″ android:orientation=”horizontal” > <Button android:id=”@+id/btn_yes” android:layout_width=”100dp” android:layout_height=”30dp” android:background=”@android:color/white” android:clickable=”true” android:text=”Yes” android:textColor=”#5DBCD2″ android:textStyle=”bold” /> <Button android:id=”@+id/btn_no” android:layout_width=”100dp” … Read more

How to prevent a dialog from closing when a button is clicked

EDIT: This only works on API 8+ as noted by some of the comments. This is a late answer, but you can add an onShowListener to the AlertDialog where you can then override the onClickListener of the button. final AlertDialog dialog = new AlertDialog.Builder(context) .setView(v) .setTitle(R.string.my_title) .setPositiveButton(android.R.string.ok, null) //Set to null. We override the onclick … Read more

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