开发者

Clickable LinearLayout not flashing on click

In my Android app, I have a LinearLayout View that contains other views. The LinearLayout is clickable, but when it is clicked, it does not flash orange like it should.

How can I get it to fl开发者_开发问答ash?


To produce the same flash effect you see when you click a listView item try this in your LinearLayout click handler:

public void onLinearLayoutClick(View v) {

  view.setBackgroundResource(android.R.drawable.list_selector_background);

  ...
}


I think you need to define 2 states for your layout if it is not natively defined for it. Have a look here if you want, it explains how to do it for a button for instance.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜