public class ReviewActivity extends Activity {
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.reviewfrag_layout);
mInflater = (LayoutInflater) ReviewActivity.this.getSystemService(
LAYOUT_INFLATER_SERVICE);
ContextThemeWrapper mTheme = new ContextThemeWrapper(this,
R.style.customDialog);
mView = mInflater.inflate(R.layout.custom_dialog, null);
// mDialog = new Dialog(this,0); // context, theme
mDialog = new Dialog(mTheme);
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.setContentView(this.mView);
//if i comment below line code runs otherwise give exception
mDialog.show();
}
}
风格:
<style name="customDialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowFrame">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowContentOverlay">@android:color/transparent</item>
<item name="android:backgroundDimEnabled">false</item>
日志消息:10-10 13:20:01.184: E/AndroidRuntime(1417): FATAL EXCEPTION: main 10-10 13:20:01.184: E/AndroidRuntime(1417): android.view.WindowManager$BadTokenException: 无法添加窗口 -- 令牌 android.app.LocalActivityManager$LocalActivityRecord@411eeaa0 无效;您的活动正在运行吗?10-10 13:20:01.184: E/AndroidRuntime(1417): 在 android.view.ViewRootImpl.setView(ViewRootImpl.java:585) 10-10 13:20:01.184: E/AndroidRuntime(1417): 在 android. view.WindowManagerImpl.addView(WindowManagerImpl.java:326) 10-10 13:20:01.184: E/AndroidRuntime(1417): 在 android.view.WindowManagerImpl.addView(WindowManagerImpl.java:224) 10-10 13:20: 01.184: E/AndroidRuntime(1417): 在 android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:149) 10-10 13:20:01.184: E/AndroidRuntime(1417): 在 android.view。