[Android] What to use instead of getResources().getColor() because this is now deprecated?
2019. 8. 7. 19:37ㆍPrograming/Android / Java
GetColor Method
int getColor (Context mContext, int id)
Returns a color connected with a particular resource ID.
[From]
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(getResource().getColor(android.R.color.white));
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(getResource().getColor(android.R.color.white));
[To]
dialog.getButton(AlertDialog.BUTTON_NEGATIVE).setTextColor(ContextCompat.getColor(getActivity(), android.R.color.white));
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setTextColor(ContextCompat.getColor(getActivity(), android.R.color.white));
'Programing > Android / Java' 카테고리의 다른 글
[GCP] Google Cloud Platform 시작하기 (0) | 2019.08.23 |
---|---|
[Android] How to add MENU in fragment ? (0) | 2019.08.07 |
Android Q에 포함된 기능동작 변경사항 (0) | 2019.08.05 |
[Android] Android Asset Studio (0) | 2019.05.22 |
[Android 9-patch] Android Asset Studio (0) | 2019.05.22 |