zoukankan      html  css  js  c++  java
  • android 实现页面的退出对话框

    activity_student_detail.xml:

    <RelativeLayout  

            android:width="match_parent"

            android:height="wrap_content"

            android:background="@android:color/holo_blue_bright">

    <Button 

           android:id= "@+id/btnBack"

           android:centerVertical="true"

           android:text="返回"

           android:width="wrap_content"

           android:height="wrap_content"/>

    <TextView

           android:width="wrap_content"

           android:height="wrap_content"

           android:text="学生详细信息"

           android:textSize="20sp"      

           android:centerVertical="true" 

          android:centerHorizontal="true"/>

    </RelativeLayout>

    this.findViewById(R.id.btnBack).setOnClickListener(new View.OnClickListener(){

        @Override                      

          public void onClick(View view){

              StudentDetailActivity.this.finish();             

          }

    });

    ListViewDemo1Activity.java:

    @Override

    public boolean onKeyUp(int keyCode,KeyEvent event){

    if(keyCode == KeyEvent.KEYCODE_BACK){    

    AlterDialog.Builder builder = new AlterDialog.Builder(ListViewDemo1Activity.this);

        builder.setTitle("温馨提示");

        builder.setMessage("你确定是否退出");

        builder.setPositiveButton("确定",new DialogInterface.OnClickListener(){

              @Override

               public void onClick(DialogInterface dialog, int which){

                            ListViewDemo1Activity.this.finish();

               }

    });

    builder.setNegativeButton("否定",new DialogInterface.OnClickListener(){

              @Override

               public void onClick(DialogInterface dialog,int which){

               }

    });

      builder.show();

    }

    return false;

    }

  • 相关阅读:
    Android Api 检查參数状态Api
    【Jquery】prop与attr的差别
    【CODEFORCES】 A. Dreamoon and Sums
    使用&lt;jsp:include&gt;,不想写死URL,动态生成URL的解决的方法
    android.app.Activity 的介绍
    字符变换
    android之获取屏幕的宽度和高度
    2015跑过的路
    hdu5418--Victor and World(floyd+状压dp)
    解决PL/SQL Developer 连接oracle 11g 64位中的问题
  • 原文地址:https://www.cnblogs.com/xiaoxiaomeng/p/5682007.html
Copyright © 2011-2022 走看看