I want to set the background android.R.attr.selectableItemBackground
to a LinearLayout
. When using XML there are no problems (it works)
<LinearLayout
android:id="@+id/llMiner"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:clickable="true" >
... but I have to do this in java code, so I've tried this
llMiner.setClickable(true);
llMiner.setBackgroundResource(android.R.attr.selectableItemBackground);
... and it doesn't work, infact I get a NotFoundException
on this second line.
So after I've tried this variant thinking that the resource is a Color.
llMiner.setClickable(true);
llMiner.setBackgroundColor(android.R.attr.selectableItemBackground);
This one doesn't launch exception, but... doesn't work (there are no changing of background when pressing, but the state change in pressed as it have to do)... any suggestion?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…