I believe settings a View.OnClickListener on the main layout element in your Dialog would do the trick :-)
Example code:
public class DialogActivity extends Activity implements OnClickListener
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog);
LinearLayout linearlayout = (LinearLayout)findViewById(R.id.dialogMainLayout);
linearlayout.setOnClickListener(this);
}
public void onClick(View v)
{
finish();
}
}
dialog.xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FFA500"
android:id="@+id/dialogMainLayout"
>
<TextView
android:layout_height="250dp"
android:layout_width="fill_parent"
android:text="TEST"
android:background="#FFFFF0"
/>
</LinearLayout>
First i tried just making an activtiy that would start another themed as a dialog. Click the dialog themed activity did absolutely nothing. So i thought that setting an onclicklistener on the root layout element in the xml-file used in the dialog themed activity might solve the problem.
I got the above code working. Hope it fixes your problem :-)