clcurie_11 2013-06-26 07:52 采纳率: 6.7%
浏览 13648

dialog 的 setCanceledOnTouchOutside 方法设置

layout xml 文件:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
    <ListView
        android:id="@+id/action_bar_item_list"
        android:layout_above="@+id/mybutton"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>
    <Button
        android:id="@+id/mybutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:text="Button" />
    <LinearLayout
        android:id="@+id/messagelayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:orientation="vertical" >
        <TextView
            android:id="@+id/message"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </LinearLayout>
</RelativeLayout>

如果点击 mybutton, messagelayout 就会设置为可见。
然而当 messagelayout 可见时,我想创建一个函数如一个对话框的 setCanceledOnTouchOutside,然而当用户在 messagelayout 边触屏时,就会设置messagelayout 消失。如果我不使用一个 dialog,如何实现呢?

  • 写回答

1条回答

  • 码密码密哄 2013-06-26 08:04
    关注

    那就用PopupWindow吧 效果和dialog差不多 也能点击外部取消

    评论

报告相同问题?

悬赏问题

  • ¥20 matlab计算中误差
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊