小编rau*_*ltm的帖子

我可以在 Google Apps Scripts 中使用 ES6 (V8) 库中定义的类吗?

我正在尝试使用在库中定义的类,但结果我只收到一个错误。

[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")

如何实例化此类的对象?

如果我跑...

在图像中我们可以看到代码和错误

记录器

我们可以看到两个日志,尝试使用类构造函数时正确使用函数和错误

v8 google-apps-script

4
推荐指数
1
解决办法
1205
查看次数

使用自定义适配器时如何获取onItemClick(ListView)中行的id?

我正在寻找一段时间,但我找不到解决方案.

情况:

我使用的是ListView和我有一个Cursor一SQLiteDatabase.query的结果.

  1. 如果我使用a SimpleCursorAdapter,当你调用时onItemClick(AdapterView<?> parent, View view, int position, long id),id返回的是_id 给定Cursor的行

  2. 但是,如果我使用自定义适配器,返回ID就像一个数组[0,1,2,3],我怎样才能在自定义适配器中设置这个id?

谢谢

android listview adapter

2
推荐指数
1
解决办法
5393
查看次数

标签 统计

adapter ×1

android ×1

google-apps-script ×1

listview ×1

v8 ×1