1

画面の 1 つに使用するポップアップの例

優先度レベルの設定に使用できるカスタム ポップアップ ビューを作成しました。最初に、ポップアップを表示するように設定しようとすると、画像の灰色の背景で示されるImageViewwithをプリセットしました。ImageView.pressed(true)

別の画像をクリックすると、クリックを登録できますが、変更を画面に表示できません。つまり、ImageView.Pressed(true)押された画像の状態をシミュレートできません。

4

1 に答える 1

0

これと同じ目的で s を使用し、リスナーImageButtonから呼び出される関連するボタンのグループの状態を設定するメソッドを用意しています。onClick()例えば、

private void configurePaletteStrokeWidth(Crayon.StrokeWidth strokeWidth) {
    findViewById(R.id.iButtonStrokeWidthSmall).setSelected(false);
    findViewById(R.id.iButtonStrokeWidthMedium).setSelected(false);
    findViewById(R.id.iButtonStrokeWidthLarge).setSelected(false);
    findViewById(R.id.iButtonStrokeWidthXLarge).setSelected(false);
    switch (strokeWidth) {
    case SMALL:
        findViewById(R.id.iButtonStrokeWidthSmall).setSelected(true);
        break;
    case LARGE:
        findViewById(R.id.iButtonStrokeWidthLarge).setSelected(true);
        break;
    case XLARGE:
        findViewById(R.id.iButtonStrokeWidthXLarge).setSelected(true);
        break;
    case MEDIUM:
        findViewById(R.id.iButtonStrokeWidthMedium).setSelected(true);
        break;
    }
}

各ボタンの xml は次のようになります。

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/button_stroke_width_small_tap" android:state_pressed="true"/> <!-- pressed -->
    <item android:drawable="@drawable/button_stroke_width_small_tap" android:state_selected="true"/> <!-- selected -->
    <item android:drawable="@drawable/button_stroke_width_small_normal" android:state_focused="true"/> <!-- focused -->
    <item android:drawable="@drawable/button_stroke_width_small_normal"/> <!-- default -->

</selector>
于 2012-11-05T14:01:44.690 に答える