Buttonのdrawableプロパティを動的に設定する

2969 ワード

0x00
Buttonにdrawableピクチャを設定し、クリックすると表示ピクチャを変更できます.いくつかのスイッチ、ステータスバーなどに適用
0x01
styles.xmlは次のプロパティを追加します.

Buttonレイアウトは次のとおりです.
<Button
    android:id="@+id/btn_next_step1"
    style="@style/ButtonSJFDNext" />

関連するクリックイベントで変更:
Drawable simLockStatusIcon = getResources().getDrawable(R.drawable.lock);
        simLockStatusIcon.setBounds(0, 0, simLockStatusIcon.getMinimumWidth(), simLockStatusIcon.getMinimumHeight());
        btnSimCardLock.setCompoundDrawables(null, null, simLockStatusIcon , null);

0 xffリファレンス:http://blog.csdn.net/scy411082514/article/details/8662348 http://blog.csdn.net/huanongjingchao/article/details/45850549