0
私は自分のアプリケーションにDrawerLayoutを実装しました。ステータスがステータスであるときにアイテムのイメージを変更することができたら欲しいです。こんにちは、引き出しのレイアウトの項目のテンプレートを表す次のコードがあります。ステータスが押されたときにアイテム全体の色を変更する方法はわかっていますが、イメージがLinearLayoutの子であるためイメージを変更する方法がわかりません。誰かが私を助けたり、私にそれをする方法を提案できますか?DrawerLayout item change image
おかげ
コード:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/CustomSelector"
android:orientation="horizontal"
android:minHeight="65dp">
<TextView
android:layout_width="3dp"
android:layout_height="match_parent"
android:background="#5AC834"
android:layout_marginTop="1dp"
android:layout_marginBottom="1dp" />
<ImageView
android:id="@+id/listImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:layout_weight="0"
android:layout_gravity="center_vertical"
android:paddingLeft="5dip" />
<TextView
android:id="@+id/listText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#334370"
android:textSize="22dip"
android:textStyle="bold"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:paddingLeft="10dip" />
</LinearLayout>
こんにちは。これは単なるアイテムであれば解決できるかもしれませんが、これはDrawerLayoutのテンプレートであり、すべてのアイテムに私のカスタムアダプタからプログラムで設定した別のイメージがあります。このようには動作しません。ありがとう – CalinCosmin
@CalinCosmin、私はプログラマチックにセレクタイメージを変更する私の答えを更新しました –