2017-07-21 3 views
1

attrを2つのダイアログテーマで使用します。
私は、ダイアログ作成しました:レイアウトでattrを使用すると、LayoutInflater.inflater(layout、null)

LayoutInflater.inflater(layout,null); 

をが、エラーました:

Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 13 

私が活動のテーマを変更することができませんでしたが。

<?xml version="1.0" encoding="utf-8"?> 
<resources> 
    <attr name="mainBackground" format="color" /> 
</resources> 


<resources xmlns:android="http://schemas.android.com/apk/res/android"> 
<style name="gl_black" parent="@android:style/Theme.Dialog"> 
    <item name="mainBackground">@color/main_background</item> 
</style> 
<style name="gl_white" parent="@android:style/Theme.Dialog"> 
    <item name="mainBackground">@color/gl_color_white</item> 
</style> 
<style name="gl_dialog_login" parent="@style/gl_black"> 
    <item name="android:windowFrame">@null</item> 
    <item name="android:windowIsFloating">true</item> 
    <item name="android:windowIsTranslucent">true</item> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:background">@android:color/transparent</item> 
    <item name="android:windowBackground">@android:color/transparent</item> 
    <item name="android:backgroundDimEnabled">true</item> 
</style> 

答えて

0

LayoutInflater.from(コンテキスト) 変更コンテキスト:
はここに私のコードです。 ContextThemeWrapper ctw =新しいContextThemeWrapper(コンテキスト、スタイル);

関連する問題