接受RelativeLayout中的点击事件 [英] accepting click events in RelativeLayout

查看:453
本文介绍了接受RelativeLayout中的点击事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 RelativeLayout 与一些 TextView 作为孩子

I have a RelativeLayout with a few TextView as children

<RelativeLayout
    android:id="@+id/shift_parent_name"
    android:layout_width="fill_parent"
    android:layout_weight="0.25"
    >
    <TextView
        android:id="@+id/shift_parent_nametitle"
        android:text="@string/shift_parent_nametitle"
        style="@style/header_text"
        />
    <TextView
        android:id="@+id/shift_parent_namefield"
        android:layout_alignParentRight="true"
        android:layout_below="@id/shift_parent_nametitle"
        style="@style/wrap"
        />

如何使用 RelativeLayout 作为按钮可以对点击事件做出反应,如果该区域的任何部分被按下?

How do I go about using the RelativeLayout as a button to react to a click event if any part of the area is pressed?

推荐答案

只需添加一个 OnClickListener 到您的RelativeLayout

Just add a OnClickListener to your RelativeLayout

这篇关于接受RelativeLayout中的点击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆