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();
    
    
        }
  • 相关阅读:
    精简的网站reset 和 css通用样式库
    bootstrap使用心得及css模块化的初步尝试
    如何更高效地定制你的bootstrap
    OOCSS的概念和思路
    圣杯布局和双飞翼布局的作用和区别
    espcms简约版的表单,提示页,搜索列表页
    Sublime快捷键
    JavaScript——理解闭包及作用
    JavaScript——基本的瀑布流布局及ajax动态新增数据
    JavaScript——之对象参数的引用传递
  • 原文地址:https://www.cnblogs.com/gisoracle/p/5204169.html
Copyright © 2011-2022 走看看