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(); }

android showmessage的更多相关文章

  1. Xamarin.Android和UWP之MVVM的简单使用(一)

    0x01 前言 就目前而言,MVVM可以说是挺流行的,无论是web端还是移动端,web端的主要代表angularjs,avalonjs等, 移动端(xamarin,uwp)的代表应该是mvvmligh ...

  2. Android 与Unity交互之Toast消息

    Toast.makeText(MainActivity.this,message.obj.toString(),Toast.LENGTH_SHORT).show();这一句代码不能直接放在 publi ...

  3. android 图片浏览器

    自定义了gallary和ImageView: gallary: public class MyGallery extends Gallery { /**  * GestureDetector类 在on ...

  4. Android遍历获取Office格式(Word,Excel,PPT,PDF)的文件并打开

    此案例主要是模仿QQ加载WPS(Word,Excel,PPT)本地文件可打开查看,使用ListView加载,使用线程扫描SD卡下所有目录加载指定的Word,Excel,PPT等格式的文件,ListVi ...

  5. Android移动APP开发笔记——Cordova(PhoneGap)通过CordovaPlugin插件调用 Activity 实例

    引言 Cordova(PhoneGap)采用的是HTML5+JavaScript混合模式来开发移动手机APP,因此当页面需要获取手机内部某些信息时(例如:联系人信息,坐标定位,短信等),程序就需要调用 ...

  6. XE7 Android 中使用 MessageDlg 范例

    MessageDlg('Choose a button:', System.UITypes.TMsgDlgType.mtInformation, [ System.UITypes.TMsgDlgBtn ...

  7. Delphi XE5 android 获取网络状态

    unit Androidapi.JNI.Network; interface function IsConnected: Boolean; function IsWiFiConnected: Bool ...

  8. Android之WebView学习

    WebView常用方法 WebSettings 在使用WebView前我们都要进行相关的配置,常见的操作如下: WebSettings settings = mWebView.getSettings( ...

  9. android 读中文文本文件

    AndroidManifest.xml中 加入: <!-- 在SDCard中创建与删除文件权限 --> <uses-permission android:name="and ...

随机推荐

  1. foreach遍历数组的表格

    <?php /** * * @authors Your Name (you@example.org) * @date 2017-03-17 19:06:19 * @version $Id$ */ ...

  2. HDU 5468 Puzzled Elena 莫比乌斯反演

    题意: 给出一棵树,每个点上有权值.然后求每棵子树中与根节点互质( \(gcd(a, b) = 1\) )的节点个数. 分析: 对于一颗子树来说,设根节点的权值为\(u\), \(count_i\)表 ...

  3. 十分钟了解socket

    socket通讯方式------socket是TCP/IP协议的网络数据通讯接口(一种底层的通讯的方式).socket是IP地址和端口号的组合.例如:192.168.1.100:8080 原理就是TC ...

  4. python 学习分享-字典篇

    python字典(Dictionary) dict是无序的 key必须是唯一切不可变的 a={'key1':'value1','key2':'value2'} 字典的增删改查 a['key3']='v ...

  5. 聊聊、Nginx 初始化日志文件

    我们接着上一篇文章继续来看看 ngx_regex_init()函数.搜索 ngx_regex_init 得到位置为src/core/ngx_regex.c:ngx_regex_init(void). ...

  6. 聊聊、Nginx 安装启动

    首先说下安装 Nginx 的步骤: (1)window 下安装 进入 http://nginx.org/en/download.html 下载版本 Mainline version 或者 Stable ...

  7. Mutual Training for Wannafly Union #8 D - Mr.BG Hates Palindrome 取余

    Mr.BG is very busy person. So you have been given enough time (1000 milliseconds) to help him. Mr. B ...

  8. C语言知识点(4)

    一.while.    dowhile. 1.while while (表达式) { 语句: … 语句: } 2.while do { printf(“%d/n,I);…}while (i<=1 ...

  9. android.os.NetworkOnMainThreadException解决办法

    代码改变世界 在发起Http请求的Activity里面的onCreate函数里面添加如下代码: StrictMode.setThreadPolicy(new StrictMode.ThreadPoli ...

  10. CSS3box-shadow属性的使用

    每次使用box-shadow,都要查阅资料才能实现对应的效果,现在总结一下,方便以后查看. 一.语法: E {box-shadow: inset x-offset y-offset blur-radi ...