【发布时间】:2017-09-28 12:56:17
【问题描述】:
在每次点击项目时,应将提及的项目应用于应用程序。
但是当我在手机中运行应用程序并选择一个选项时,主题不会改变,吐司也不会出现。
没有错误出现,应用程序也没有崩溃。它只是不起作用。
而且我愿意通过一个微调器来做到这一点。我该怎么办?
这是我的代码:
final ListView themeList = (ListView) findViewById(R.id.themeList);
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (position == 0) {
getApplicaiton().setTheme(R.style.themeOne);
} else if (position == 1) {
getApplicaiton().setTheme(R.style.themeTwo);
} else if (position == 2) {
getApplicaiton().setTheme(R.style.themeThree);
} else {
Toast.makeText(ThemeActivity.this, "Something went wrong, please try again!", Toast.LENGTH_SHORT).show();
}
};
【问题讨论】:
-
如果更改主题,则必须重新启动 Activity 才能看到更改。
标签: java android themes android-theme android-styles