2016-11-25 18 views
0

getColor(int)は推奨されていません。getColor(int)getColor(int、theme theme)を使用する方法はありません

どうすればgetColor(int, theme theme)を使用できますか?

私はいくつかのレッスンを使用しましたが、私はどのように使用することができませんgetColor(int, theme theme)

+0

あなたがリソースを見たことがありますか? https://developer.android.com/reference/android/content/res/Resources.html#getColor(int、android.content.res.Resources.Theme) –

答えて

2

使用

ResourcesCompat.getColor(getResources(), R.color.red, null) 

として何か(それはnullかもしれので、以前のAPIレベル23にテーマが適用されません。)

+0

私は 'context.getTheme()'を使うのではなく、 'null'を使うか、あるいは廃止予定のメソッドを使うこともできます。 –

関連する問題