简体   繁体   English

delphi android,如何在初始化程序中使用JAttributeSet?

[英]delphi android, how to use JAttributeSet in init procedure?

I need to create a JEditText, so i found theses methods : 我需要创建一个JEditText,所以我找到了以下方法:

  JEditTextClass = interface(JTextViewClass)
    ['{A1E1255C-8FC9-449A-A886-57ABA315C3E3}']
    {class} function init(context: JContext): JEditText; cdecl; overload;
    {class} function init(context: JContext; attrs: JAttributeSet): JEditText; cdecl; overload;
    {class} function init(context: JContext; attrs: JAttributeSet; defStyleAttr: Integer): JEditText; cdecl; overload;
    {class} function init(context: JContext; attrs: JAttributeSet; defStyleAttr: Integer; defStyleRes: Integer): JEditText; cdecl; overload;

end; 结束;

but i can't understand how to set (and with what?) 但我不明白如何设置(以及使用什么?)

attrs: JAttributeSet; 
defStyleAttr: Integer; 
defStyleRes: Integer

I'd suggest the more flexible constructors are there for those who need them. 我建议为那些需要它们的人提供更灵活的构造函数。 If you don't know what to pass to them, perhaps you don't need them. 如果您不知道该如何传递给他们,也许您就不需要它们。

The DPF code that wraps up an Android EditText uses the simplest constructor - see TDPFJEditText.Create in DPF.Android.JEditText.pas . 包装Android EditTextDPF代码使用最简单的构造函数-请参阅TDPFJEditText.Create中的TDPFJEditText.Create

Additionally, looking at the Android documentation for AttributeSet , it would appear these tend to get created to represent attributes found in the XML definitions of Android resources, something we have no typical use of in Delphi Android apps. 另外,查看AttributeSet的Android文档 ,似乎会倾向于创建这些属性来表示在Android资源的XML定义中找到的属性,这在Delphi Android应用程序中通常没有使用。

I would suggest you use the simple constructor to create your object and then employ the various properties and methods of the created EditText . 我建议您使用简单的构造函数创建对象,然后使用创建的EditText的各种属性和方法。 Don't get bogged down in the intricacies of the underpinnings of the resources that typically go to make up a Java Android app. 不要被构成Java Android应用程序的各种资源的基础所困扰。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM