ResourcesCompat 构造函数具有私有访问权限
ResourcesCompat constructor has private acess
错误非常清楚,但是 google android 文档说构造函数是 public.
我在我的应用程序中使用了以下代码
import android.support.v4.content.res.ResourcesCompat;
final ResourcesCompat resourcesCompat = new ResourcesCompat();
final int foreground = resourcesCompat.getColor(getResources(), night ? R.color.night_status_bar_text : R.color.status_bar_text, getTheme());
final int background = resourcesCompat.getColor(getResources(), night ? R.color.night_game_background : R.color.game_background, getTheme());
statusBar.setTextColor(foreground);
我添加了 android-v4 支持库最新版本 (support-v4 24.0.0)。 Android 工作室给出 'ResourcesCompat constructor has private access' 但 google 文档说构造函数是 public。
请帮我解决这个问题。
使用目前最新的23.2.1。 (2016 年 3 月)
查看 this 网站了解更多信息。
我已经用这个版本测试过了。它工作正常,构造函数实际上是 public.
更新:
好的我找到了ResouresCompat v24
如我所料,getColor
和 getColorStateList
现在是静态的。所以不需要使用构造函数。
将您的代码更新为:
final int foreground = ResouresCompat.getColor(getResources(), night ? R.color.night_status_bar_text : R.color.status_bar_text, getTheme());
final int background = ResouresCompat.getColor(getResources(), night ? R.color.night_game_background : R.color.game_background, getTheme());
但请记住,这只是预览。
错误非常清楚,但是 google android 文档说构造函数是 public.
我在我的应用程序中使用了以下代码
import android.support.v4.content.res.ResourcesCompat;
final ResourcesCompat resourcesCompat = new ResourcesCompat();
final int foreground = resourcesCompat.getColor(getResources(), night ? R.color.night_status_bar_text : R.color.status_bar_text, getTheme());
final int background = resourcesCompat.getColor(getResources(), night ? R.color.night_game_background : R.color.game_background, getTheme());
statusBar.setTextColor(foreground);
我添加了 android-v4 支持库最新版本 (support-v4 24.0.0)。 Android 工作室给出 'ResourcesCompat constructor has private access' 但 google 文档说构造函数是 public。
请帮我解决这个问题。
使用目前最新的23.2.1。 (2016 年 3 月)
查看 this 网站了解更多信息。
我已经用这个版本测试过了。它工作正常,构造函数实际上是 public.
更新:
好的我找到了ResouresCompat v24
如我所料,getColor
和 getColorStateList
现在是静态的。所以不需要使用构造函数。
将您的代码更新为:
final int foreground = ResouresCompat.getColor(getResources(), night ? R.color.night_status_bar_text : R.color.status_bar_text, getTheme());
final int background = ResouresCompat.getColor(getResources(), night ? R.color.night_game_background : R.color.game_background, getTheme());
但请记住,这只是预览。