Android Activity as a dialog

To start activity as dialog I defined it like this in AndroidManifest.xml: <activity android:theme=”@android:style/Theme.Dialog” /> Use this property inside your activity tag to avoid that your Dialog appears in the recently used apps list android:excludeFromRecents=”true” If you want to stop your dialog / activity from being destroyed when the user clicks outside of the dialog: … 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

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