4
私のアプリケーションには一般的な主なアクティビティがあります。 主な活動は、新しいアイコンを追加するには、このようにアクティビティのテーマを動的に変更する
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="home_buttons_text">
<item>@string/Title_1</item>
</string-array>
<array name="home_buttons_icon">
<item>@drawable/google</item>
</array>
<string-array name="home_buttons_url">
<item>http://www.google.com</item>
</string-array>
<array name="themes">
<item>@style/my_theme</item>
</array>
</resources>
に従ってください、私はちょうどここに新しい行を置くようarrays.xmlから設定を読み込みます。
「テーマ」ではテーマの名前があります。名前で呼び出されたテーマを読み込んで適用する方法は?私は
TypedArray mItemsIcons = resources.obtainTypedArray(R.array.home_buttons_icon);
TypedArray mThemes = resources.obtainTypedArray(R.array.themes);
.
.
.
mItemsIcons.getDrawable(position);
.
.
.
を使用しました。しかし、私はテーマを取得する方法については考えてきたんアイコンの
。 私はテストしました
int theme = mThemes.getResourceId(position);
setTheme(theme);
しかし、動作しません。詳細については、こちらを
はチェック:http://developer.android.com/guide/topics/resources/more-resources.html#TypedArray
:http://javarticles.com/2015/04/android- set-theme-dynamically.html – 8m47x