selectorタグを用いたxmlファイルを使う時がわかりません。
Java
1<?xml version="1.0" encoding="utf-8"?> 2<selector xmlns:android="http://schemas.android.com/apk/res/android" 3 android:layout_width="match_parent" 4 android:layout_height="match_parent"> 5 6 <item android:drawable="@drawable/hert" android:state_pressed="true" /> 7 <item android:drawable="@drawable/pic" android:state_pressed="true" /> 8</selector>
と本の通りコードを記述したのですが、
activity_main.xmlに書かない理由はmultiple root tagになってしまうからでしょうか?
(どうして1つのxmlに2つのroot tagを書くとダメなのでしょうか?コンパイルエラーとかが起こるのでしょうか?)
またselector tagを使う時がよくわかりません。選択肢を作る時に使うtagといった感じなのでしょうか?
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
退会済みユーザー
2016/09/05 01:09
2016/09/05 02:37