我正在尝试使用在库中定义的类,但结果我只收到一个错误。
[LibraryProject]/library/model/Update.gs
class Update {
constructor(obj = {}) {
if(typeof obj == "string"){
options = JSON.parse(obj);
}
Object.assign(this, obj);
}
text(){
return (this.message && this.message.text)?this.message.text:''
}
}
Run Code Online (Sandbox Code Playgroud)
任务
? 创建项目的新版本。(文件 > 管理版本...)
? 在另一个项目中加载这个库 [别名:CustomService] (资源 > 库...)
? 使用 CustomService 的功能
? 使用 CustomService 类
如果我尝试使用类
[普通项目]/index.gs
function test (){
Logger.log(CustomService.libraryFunction())
var update = new CustomService.Update("");
Logger.log(update)
}
Run Code Online (Sandbox Code Playgroud)
TypeError: CustomService.Update is not a constructor (line 3, archivo "Code")
如何实例化此类的对象?
如果我跑...
记录器
我正在寻找一段时间,但我找不到解决方案.
情况:
我使用的是ListView和我有一个Cursor一SQLiteDatabase.query的结果.
如果我使用a SimpleCursorAdapter,当你调用时onItemClick(AdapterView<?>
parent, View view, int position,
long id),id返回的是_id
给定Cursor的行
但是,如果我使用自定义适配器,返回ID就像一个数组[0,1,2,3],我怎样才能在自定义适配器中设置这个id?
谢谢