Android getResources()メソッドの古い代替方法
521 ワード
1.getResources().getColor()メソッドが古い
2.getResources().getDrawable()メソッドは古い
(1).drawableリソースを使用してthemeトピックを設定しない
(2).デフォルトのactivityトピックを使用
(3).カスタムトピックの使用
ContextCompat.getColor(context, R.color.black);
2.getResources().getDrawable()メソッドは古い
(1).drawableリソースを使用してthemeトピックを設定しない
ResourcesCompat.getDrawable(getResources(), R.drawable.name, null);
(2).デフォルトのactivityトピックを使用
ContextCompat.getDrawable(getActivity(), R.drawable.name);
(3).カスタムトピックの使用
ResourcesCompat.getDrawable(getResources(), R.drawable.name, anotherTheme);