I have an Activity named whereActity
which has child dialogs as well. Now, I want to display this activity as a dialog for another activity.
How can I d
Some times you can get the Exception which is given below
Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
So for resolving you can use simple solution
add theme of you activity in manifest as dialog for appCompact.
android:theme="@style/Theme.AppCompat.Dialog"
It can be helpful for somebody.
Set the theme in your android manifest file.
<activity android:name=".LoginActivity"
android:theme="@android:style/Theme.Dialog"/>
And set the dialog state on touch to finish.
this.setFinishOnTouchOutside(false);
If you want to remove activity header & provide a custom view for the dialog add the following to the activity block of you manifest
android:theme="@style/Base.Theme.AppCompat.Dialog"
and design your activity_layout with your desired view
1 - You can use the same activity as both dialog and full screen, dynamically:
Call setTheme(android.R.style.Theme_Dialog)
before calling setContentView(...)
and super.oncreate()
in your Activity.
2 - If you don't plan to change the activity theme style you can use
<activity android:theme="@android:style/Theme.Dialog" />
(as mentioned by @faisal khan)