【问题标题】:Change Theme (setTheme) class android Utils "this" error in Fragment更改主题(setTheme)类android Utils片段中的“this”错误
【发布时间】:2015-08-17 08:12:42
【问题描述】:

你好,我有一个 Utils 类和一个片段类 片段类:http://pastebin.com/uybNJPpe

Utils 类:http://pastebin.com/fpSq1wP2

在我的片段类中的“this”上,我收到此错误: 无法应用Utils中的onActivityCreateSetTheme(android.app.activity) 你们能帮帮我吗?求求你了,谢谢你。 我投票给最好的!

【问题讨论】:

  • 使用getActivity() 而不是this
  • 你好,我试过了,但我得到了这个错误:Error:(41, 50) error: as of release 8, 'this' is allowed as the parameter name for the receiver type, which必须是第一个参数

标签: java android android-fragments set themes


【解决方案1】:

通过在您的片段中使用this,您将获得片段实例。

但在您的onActivityCreateSetTheme 方法中,参数是Activity

因此,为了获得Activity 实例,您应该在片段中传递getActivity(),而不是使用this

【讨论】:

  • 完美运行!谢谢。等 5 分钟,我投票给你 ;)
猜你喜欢
  • 1970-01-01
  • 2020-05-28
  • 1970-01-01
  • 2015-03-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多