어떻게 주어진 활동 매개 변수와 정적 메서드에서 수퍼 클래스를 사용하는 방법?

hyperapps19 :

나는`m 내 활동 등 언어 설정, 테마에 사용되는 정적 클래스 ActivitySetup을 만들려고. 나는 테마를 설정에 문제가 있습니다. 지금은 코드를 다음 있습니다 :

     static void configureTheme(Activity activity, int defaultTheme) {
     String theme = PreferenceManager.getDefaultSharedPreferences(activity).getString("theme", "light");
     assert theme != null;

     switch (theme) {
         case "light":
             activity.setTheme(R.style.AppTheme);
             break;
         case "dark":
             activity.setTheme(R.style.Theme_AppCompat);
             break;
         default:
             activity.setTheme(defaultTheme);
             break;
     }
 }

그러나 충돌합니다. 난 내가 사용해야 알고 super (of activity).setTheme대신 activity.setTheme하지만, 내가 어떻게 그렇게 할 수 있습니까? 어떻게 정적 메서드에 매개 변수로 슈퍼 클래스의 인스턴스를 전달하는 방법?

Yagnesh Lashkari :

테마 사이의 스위치를 동적으로 당신은 단순히 호출 할 필요가 setTheme전에super.onCreate

public void onCreate(Bundle savedInstanceState) {
    setTheme(android.R.style.Theme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

추천

출처http://43.154.161.224:23101/article/api/json?id=118349&siteId=1