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. hdu 1011 Starship Troopers(树形背包)

    Starship Troopers Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Other ...

  2. iOS开发~CocoaPods安装和使用

    随着 iOS 开发者的增多,业界也出现了为 iOS 程序提供依赖管理的工具,它的名字叫做:CocoaPods. CocoaPods项目的源码 在 Github 上管理.该项目开始于 2011 年 8 ...

  3. Selenium WebDriver-actionchain模拟鼠标右键操作

    #encoding=utf-8 import unittest import time from selenium import webdriver from selenium.webdriver i ...

  4. LiveScript 操作符

    The LiveScript Book     The LiveScript Book 操作符 数字 标准的数学操作符: 1.1 + 2 # => 32.3 - 4 # => -13.6 ...

  5. Leetcode 480.滑动窗口中位数

    滑动窗口中位数 中位数是有序序列最中间的那个数.如果序列的大小是偶数,则没有最中间的数:此时中位数是最中间的两个数的平均数. 例如: [2,3,4],中位数是 3 [2,3],中位数是 (2 + 3) ...

  6. [持续集成学习篇]【1】[jenkins安装与配置]

    Guided Tour This guided tour will use the "standalone" Jenkins distribution which requires ...

  7. [译]pandas中的iloc loc的区别?

    loc 从特定的 gets rows (or columns) with particular labels from the index. iloc gets rows (or columns) a ...

  8. hdu 2665 划分树模板题(可作为模板)

    Kth number Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  9. 让Android软键盘默认进入英文键盘

    今天在做一个功能的 时候,需要输入法软键盘弹出后,需要进入英文输入界面. 可以通过设置EditText的输入类型为EMAIL来实现.     //将输入法切换到英文     edit.setInput ...

  10. hdu6097[二分+解析几何] 2017多校6

    /*hdu6097[二分+解析几何] 2017多校6*/ #include <bits/stdc++.h> using namespace std; ; struct node{ doub ...