zoukankan      html  css  js  c++  java
  • android showmessage

    package com.example.yanlei.yl6;
    import android.annotation.TargetApi;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.content.DialogInterface;
    import android.content.pm.ApplicationInfo;
    import android.content.pm.PackageManager;
    import android.os.Build;
    import android.os.Bundle;
    import android.os.Handler;
    import android.view.MotionEvent;
    import android.view.View;
    import android.widget.Toast;
    public void ShowMessage(String str) {
            Toast.makeText(this, str, Toast.LENGTH_LONG).show();
    
        }
    
        public String getApplicationName() {
            PackageManager packageManager = null;
            ApplicationInfo applicationInfo = null;
            try {
                packageManager = getApplicationContext().getPackageManager();
                applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
            } catch (PackageManager.NameNotFoundException e) {
                applicationInfo = null;
            }
            String applicationName =
                    (String) packageManager.getApplicationLabel(applicationInfo);
            return applicationName;
        }
    
        public void ShowMessage1(String str) {
            new AlertDialog.Builder(this)
                    .setTitle(getApplicationName())
                    .setMessage(str)
                    .show();
    
        }
    
        public void ShowMessage2(String str) { //
            new AlertDialog.Builder(this)
                    .setMessage(str)
                    .setPositiveButton("确定",
                            new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialoginterface, int i) {
                                    //按钮事件
                                }
                            })
                    .show();
        }
    
        public void ShowMessage3(String str) { //
    
            new AlertDialog.Builder(this)
                    .setTitle("提示")
                    .setMessage(str)
                    .setIcon(R.drawable.quit)
                    .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            setResult(RESULT_OK);//确定按钮事件
                            finish();
                        }
                    })
                    .setNegativeButton("取消", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int whichButton) {
                            //取消按钮事件
                        }
                    })
                    .show();
    
    
        }
  • 相关阅读:
    NFine框架JqGrid导出选中行为Excel实现方法
    NFine框架全选checkBox列错位
    VS 在文件中查找替换界面死掉。
    WCF各个Service之间共享数据
    Devexpress Winform 使用MVVM
    FontAwesome图标选择器
    Xampp PHPStorm XDebug配置
    SDL 库 无法解析的外部符号 __imp__fprintf
    ffmpeg mp4转yuv
    JAVA环境变量配置
  • 原文地址:https://www.cnblogs.com/gisoracle/p/5204169.html
Copyright © 2011-2022 走看看