実現したいこと
発生している問題
style.xml で buttonBarPositiveButtonStyle
を定義し、AlertDialog.Builder
の引数に設定したが正しく適用されない。ダイアログ全体へのスタイル設定( CalenderDialog
)は正しく適用されている。
該当のソースコード
style.xml
xml
1<resources> 2 3 <!-- Base application theme. --> 4 <style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar"> 5 <!-- Customize your theme here. --> 6 <item name="colorPrimary">@color/colorPrimary</item> 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 8 <item name="colorAccent">@color/colorAccent</item> 9 </style> 10 11 <!-- AlertDialog --> 12 <style name="CalenderDialog" parent="Theme.MaterialComponents.Light.Dialog"> 13 <item name="colorAccent">#000000</item> 14 <item name="android:windowMinWidthMajor">95%</item> 15 <item name="android:windowMinWidthMinor">95%</item> 16 <item name="buttonBarPositiveButtonStyle">@style/PositiveButtonStyle</item> 17 <item name="buttonBarNegativeButtonStyle">@style/NegativeButtonStyle</item> 18 </style> 19 20 <style name="PositiveButtonStyle"> 21 <item name="android:textColor">#1EA5E1</item> 22 </style> 23 24 <style name="NegativeButtonStyle"> 25 <item name="android:textColor">#1EA5E1</item> 26 </style> 27</resources>
AlertDialog の生成
kotlin
1class CalenderDialogFragment:DialogFragment(){ 2 3 override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { 4 var builder = AlertDialog.Builder(activity,R.style.CalenderDialog) 5 6 // カレンダーの日付部分の実装 7 val view = activity!!.layoutInflater.inflate(R.layout.fragment_dialog_calender, null, false) 8 var dateList = arrayListOf<String>("1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1") 9 view.date_list_in_calender.layoutManager = GridLayoutManager(activity,7) 10 view.date_list_in_calender.adapter = CalnderListAdapter(dateList) 11 12 // ボタンの追加 13 builder.setPositiveButton("OK", null) 14 builder.setNegativeButton("キャンセル", null) 15 builder.setNeutralButton("オプション", null) 16 17 builder.setView(view) 18 return builder.create() 19 } 20}
補足
上記で必要な情報が欠如しているようであれば追記いたします。ご指摘いただけると助かります。
どうぞよろしくお願いします..!
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/01 10:25