android点击linearlayout没反应,从不调用LinearLayout的点击监听器

|

试图让onclick侦听器在线性布局上工作,但从未调用过:(。已启用clickable和focsuable(两种模式),但仍无法使Click侦听器响应。平台详细信息:Android 3.0。

android:id=\"@+id/menu_items_button\"

android:layout_width=\"0dip\"

android:layout_height=\"fill_parent\"

android:layout_weight=\"1\"

android:orientation=\"vertical\"

android:gravity=\"center_horizontal\"

android:paddingTop=\"@dimen/gen_margin_xsmall\"

android:paddingBottom=\"@dimen/gen_margin_xsmall\"

android:background=\"@drawable/rule_bg_menu_button\"

android:clickable=\"true\"

android:focusableInTouchMode=\"true\"

>

android:layout_width=\"wrap_content\"

android:layout_height=\"wrap_content\"

android:src=\"@drawable/menu_items\"

android:tag=\"image\"

/>

android:layout_width=\"wrap_content\"

android:layout_height=\"wrap_content\"

android:tag=\"text\"

android:text=\"@string/menu_items_icon_txt\"

style=\"@style/textDisplay.mediumLarge\"

/>

并在代码中添加事件监听器

_itemsButton = (LinearLayout) menu.findViewById(R.id.menu_items_button);

final Intent itemsIntent = new Intent(this, ItemsActivity.class);

_itemsButton.setOnClickListener(

new View.OnClickListener() {

@Override

public void onClick(View v) {

startActivity(itemsIntent); //Never called!

}

}

);

我这样做而不使用“图像”按钮的原因是因为““按钮””的背景是基于状态的(渐变),但是图像也是基于状态的,以便在单击/聚焦时将两者结合在一起,我使用了一个其自身具有ImageView的linearlayout。有关clickListener为什么不能在linearLayout上工作的任何建议?

谢谢

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值