RelativeLayout的切换按钮和 [英] relativelayout and togglebutton

查看:115
本文介绍了RelativeLayout的切换按钮和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的main.xml

This my main.xml

<RelativeLayout android:id="@+id/gloabal_permission"
                        android:layout_height="fill_parent" android:layout_width="wrap_content"
                        android:background="@drawable/settings_selector_down"
                        android:paddingTop="3dp" android:paddingBottom="3dp"
                        android:paddingRight="12dp" android:paddingLeft="15dp">
                        <TextView android:id="@+id/TextView06"
                            android:layout_height="wrap_content" android:layout_width="wrap_content"
                            android:text="Gloabal permission" android:layout_marginTop="10dp">
                        </TextView>
                        <ToggleButton android:id="@+id/globalpermissionbutton"
                            android:layout_width="wrap_content" android:layout_height="wrap_content"
                            android:text="ToggleButton" android:layout_alignParentRight="true">
                        </ToggleButton>
    </RelativeLayout>

我应该怎么做,当我点击切换按钮RelativeLayout的是打开(点击一次切换按钮被关闭)。我只是wnat占用relativelayoutlistener与切换按钮的侦听器。

What should I do so when I click on relativelayout togglebutton is turn on (click one more time toggle button is turn off). I just wnat tie up relativelayoutlistener with togglebutton's listener.

推荐答案

您必须创建一个的onClick()监听器为您的相对布局。
例如:

You have to create a onClick() listener for your relative layout for that. Eg.

yourRelLayout.setOnClickListener(new OnClickListener({
  yourToggleButton.setChecked(true);
}));

这是所有:)

祝你好运!

这篇关于RelativeLayout的切换按钮和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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