unit Android.JNI.Toast;

// Java bridge class imported by hand by Brian Long (http://blong.com)
interface

{$IFDEF ANDROID}

uses
Androidapi.JNIBridge,
Androidapi.JNI.JavaTypes,
Androidapi.JNI.GraphicsContentViewText;
{$ENDIF}
{$IFDEF ANDROID}

type
TToastLength = (LongToast, ShortToast);

JToast = interface;

JToastClass = interface(JObjectClass)
['{69E2D233-B9D3-4F3E-B882-474C8E1D50E9}']
{ Property methods }
function _GetLENGTH_LONG: Integer; cdecl;
function _GetLENGTH_SHORT: Integer; cdecl;
{ Methods }
function init(context: JContext): JToast; cdecl; overload;
function makeText(context: JContext; text: JCharSequence; duration: Integer)
: JToast; cdecl;
{ Properties }
property LENGTH_LONG: Integer read _GetLENGTH_LONG;
property LENGTH_SHORT: Integer read _GetLENGTH_SHORT;
end;

[JavaSignature('android/widget/Toast')]
JToast = interface(JObject)
['{FD81CC32-BFBC-4838-8893-9DD01DE47B00}']
{ Methods }
procedure cancel; cdecl;
function getDuration: Integer; cdecl;
function getGravity: Integer; cdecl;
function getHorizontalMargin: Single; cdecl;
function getVerticalMargin: Single; cdecl;
function getView: JView; cdecl;
function getXOffset: Integer; cdecl;
function getYOffset: Integer; cdecl;
procedure setDuration(value: Integer); cdecl;
procedure setGravity(gravity, xOffset, yOffset: Integer); cdecl;
procedure setMargin(horizontalMargin, verticalMargin: Single); cdecl;
procedure setText(s: JCharSequence); cdecl;
procedure setView(view: JView); cdecl;
procedure show; cdecl;
end;

TJToast = class(TJavaGenericImport<JToastClass, JToast>)
end;

procedure Toast(const Msg: string; duration: TToastLength = ShortToast);

{$ENDIF}

implementation

{$IFDEF ANDROID}

uses
FMX.Helpers.Android;

procedure Toast(const Msg: string; duration: TToastLength);
var
ToastLength: Integer;
begin
if duration = ShortToast then
ToastLength := TJToast.JavaClass.LENGTH_SHORT
else
ToastLength := TJToast.JavaClass.LENGTH_LONG;
CallInUiThread(
procedure
begin
TJToast.JavaClass.makeText(SharedActivityContext, StrToJCharSequence(Msg),
ToastLength).show
end);
end;
{$ENDIF}

end.

delphi android 中 Toast 的实现(老外写的UNIT)的更多相关文章

  1. Toast工具类,Android中不用再每次都写烦人的Toast了

    package com.zhanggeng.contact.tools; /** * Toasttool can make you use Toast more easy ; * * @author ...

  2. Android中Toast的用法简介

    转自:http://www.cnblogs.com/GnagWang/archive/2010/11/26/1888762.html Toast是Android中用来显示显示信息的一种机制,和Dial ...

  3. Android中土司(Toast)的使用

     Android中Toast的使用 什么是土司(Toast)? Toast是Android系统提供的一种非常好的提示方式,在程序中可以使用它将一些短小的信息通知给用户,这些信息会在一段时间后自动消失, ...

  4. android中的提示信息显示方法(toast应用)

    android中的提示信息显示方法(toast应用) (2011-10-17 11:02:06) 转载▼ 标签: android toast 杂谈 分类: Android android中toast的 ...

  5. Android 更改 Toast 的默认位置

    Android中Toast的默认位置在屏幕靠近底部的位置,这个默认位置有时候并不合适.比如页面上内容较少时,内容一般集中在屏幕上半部分,用户的注意力也集中在屏幕上半部分,默认位置的Toast用户可能没 ...

  6. android中全局异常捕捉

    android中全局异常捕捉 只要写代码就会有bug,但是我们要想办法收集到客户的bug.有第三方bugly或者友盟等可以收集.但是,android原生就提供了有关收集异常的api,所以我们来学习一下 ...

  7. 在Android中调用C#写的WebService(附源代码)

    由于项目中要使用Android调用C#写的WebService,于是便有了这篇文章.在学习的过程中,发现在C#中直接调用WebService方便得多,直接添加一个引用,便可以直接使用将WebServi ...

  8. 在Android中把内容写到XML文件中

    在Android中把内容写到XML文件中 saveXmlButton.setOnClickListener(new OnClickListener() { @Override public void ...

  9. Delphi XE8中Android开发有用的资源!

    一,FireMonkey Component Library在XE8帮助(topics.chm)中的位置:FireMonkey Component Library,展示了FireMonkey控件在VC ...

随机推荐

  1. 安装 Python

    Python安装.配置图文详解 一. Python简介: Python在Linux.windows.Mac os等操作系统下都有相应的版本,不管在什么操作系统下,它都能够正常工作.除非使用平台相关功能 ...

  2. BPMN

    1.私有业务流程: 特定行业规则制度比如惠普生产线流程-针对业务人员 2.公有业务流程: 技术实现-针对流程开发人员 http://www.blogjava.net/RongHao/archive/2 ...

  3. 解决oralce 11g dg搭建报错:ORA-16664、ORA-16714、ORA-16810问题--转

    下面不是小编错误报告只是转了网络一篇,同时也解决了我的问题所以复制过来给各位参考. 最近在弄11g的dg时,遇到如下问题,记录下.首先在主上查看报如下错误: DGMGRL> show confi ...

  4. Problem 1274 - 可怜的lpx

    Problem 1274 - 可怜的lpx Time Limit: 1000MS   Memory Limit: 65536KB    Description 可怜的lpx终于在别人的帮助下追上了aq ...

  5. windows Phone 浏览器窗口的尺寸

    移动设备的屏幕一般都比PC小很多,移动设备的浏览器会将一个较大的  “虚拟”  窗口映射到移动设备的屏幕上,然后按一定的比例(3:1或2:1)进行缩放.也就是说当我们加载一个普通网页的时候,移动浏览器 ...

  6. TFS客户端登录用户修改

    1.操作环境: Windows 10 Pro Visual Studio 2013 TFS客户端 2.操作背景 安装完成TFS系统后,使用administrator在客户端进行登陆测试(已勾选保存用户 ...

  7. 如何设置修改WPS批注上的用户信息名称

    http://jingyan.baidu.com/article/6b18230953cec7ba59e1596b.html 点击左上角的“WPS文字”:   选择“选项”:   点击“用户信息”: ...

  8. 简单几步优化技巧令你的Windows7系统加速

    就算有再高的硬件配置,系统用久了还是会变慢,xp如此,win7同样是如此.其实系统用的如何完全在于个人使用习惯,只要掌握了以下三种方法,就可以让你的win7运行速度大大提升. 1.修改启动项程序 在你 ...

  9. php接口post提交方法 。

    方法一,用 file_get_contents function send_post($url, $post_data) { //$postdata = http_build_query($post_ ...

  10. JS实现星级评分

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...