原始代码转自:http://www.voidcn.com/article/p-aabzkllf-pv.html
修改后源码pas文件下载:http://www.colafile.com/file/2588729
{***************************************************************************}{ }{ 功能:AndroID Toast提示消息框 }{ 名称:AndroIDAPI.JNI.Widget.Toast.pas }{ 版本:1.0 }{ 环境:Win7 Sp1 64bit }{ 工具:Delphi XE7 }{ 日期:2014-11-23 19:45:35 }{ 用法:TToast.Show(MessageText,isLongHint) }{--------------------------------------------------------------------------}{ 原版作者:ying32 }{ QQ:396506155 }{ MSN :ying_32@live.cn }{ E-mail:yuanfen3287@vip.qq.com }{ Website:http://blog.csdn.net/zyjying520/article/details/26158941 }{ 版权所有 (C) 2013-2013 ying32.tk All Rights Reserved }{---------------------------------------------------------------------------}{ 修改者:tht2009 }{ 改动:1、去掉注释掉的方法 }{ 2、移动FMX.Helpers.AndroID引用声明到实现区 }{ 3、增加AndroIDAPI.Helpers引用 }{ }{***************************************************************************}unit AndroIDAPI.JNI.Widget.Toast;interfaceuses AndroIDAPI.JNIBrIDge,AndroIDAPI.JNI.JavaTypes,AndroIDAPI.JNI.GraphicsContentVIEwText;type JToast = interface;//androID.Widget.Toast JToastClass = interface(JObjectClass) ['{CF455B66-683D-41F9-B386-0C49E42D4F92}'] {Property Methods} function _GetLENGTH_LONG: Integer; function _GetLENGTH_SHORT : Integer; {Methods} // public Toast (Context context) function init(context: JContext): JToast; cdecl; // public static Toast makeText (Context context,int resID,int duration) function makeText(context: JContext; resID: Integer; duration: Integer): JToast;cdecl;overload; // public static Toast makeText (Context context,CharSequence text,int duration) function makeText(context: JContext; text: JCharSequence; duration: Integer): JToast;cdecl;overload; {PropertIEs} property LENGTH_LONG: Integer read _GetLENGTH_LONG; property LENGTH_SHORT: Integer read _GetLENGTH_SHORT; end; [JavaSignature('androID/Widget/Toast')] JToast = interface(JObject) ['{4A284317-000C-4048-8674-C475F505CFAF}'] {Methods} // public voID cancel () procedure cancel;cdecl; // public int getDuration () function getDuration: Integer; cdecl; // public int getGravity () function getGravity: Integer; cdecl; // public float getHorizontalmargin () function getHorizontalmargin: Single; cdecl; // public float getVerticalmargin () function getVerticalmargin: Single; cdecl; // public VIEw getVIEw () function getVIEw: JVIEw; cdecl; // public int getXOffset () function getXOffset: Integer; cdecl; // public int getYOffset () function getYOffset: Integer; cdecl; // public voID setDuration (int duration) procedure setDuration(duration: Integer); cdecl; // public voID setGravity (int gravity,int xOffset,int yOffset) procedure setGravity(gravity,xOffset,yOffset: Integer);cdecl; // public voID setmargin (float horizontalmargin,float verticalmargin) procedure setmargin(horizontalmargin,verticalmargin: Single);cdecl; // public voID setText (int resID) procedure setText(resID: Integer);cdecl;overload; // public voID setText (CharSequence s) procedure setText(s: JCharSequence);cdecl;overload; // public voID setVIEw (VIEw vIEw) procedure setVIEw(vIEw: JVIEw);cdecl; // public voID show () procedure show;cdecl; end; TJToast = class(TJavaGenericimport<JToastClass,JToast>) end; { TToast } TToast = class public class procedure Show(const text: string; LongHint: Boolean = False); end;implementationuses FMX.Helpers.AndroID,AndroIDAPI.Helpers;{ TToast }class procedure TToast.Show(const text: string; LongHint: Boolean);var LDuration: Integer;begin CallinUIThread ( procedure begin case LongHint of True : LDuration := TJToast.JavaClass.LENGTH_LONG; False : LDuration := TJToast.JavaClass.LENGTH_SHORT; end; TJToast.JavaClass.makeText(SharedActivityContext,StrToJCharSequence(text),LDuration).show; end );end;end.总结
以上是内存溢出为你收集整理的delphi android Toast全部内容,希望文章能够帮你解决delphi android Toast所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)