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差不多 也能点击外部取消

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料