首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Neko中产生缺陷型NoSuchMethodException

在Neko中产生缺陷型NoSuchMethodException
EN

Stack Overflow用户
提问于 2014-07-23 20:06:56
回答 1查看 62关注 0票数 1

我开始学习尼科的教程,我想要创建自己的特性。我一直在跟踪描述这里的关于neko的文档,但是它总是产生错误。

更具体而言:

代码语言:javascript
复制
; Clojure code

(ns main
  (:use [neko.activity :only [defactivity set-content-view!]]
        [neko.threading :only [on-ui]]
        [neko.ui :only [make-ui config]]
        [neko.ui.traits :only [deftrait]]))

(deftrait :on-text-change
  {:attributes [:on-text-change]}
  [^android.widget.TextView wdg, {:keys [on-text-change]}, opts]
  (.addTextChangedListener wdg (reify android.text.TextWatcher
                                 (afterTextChanged [this _])
                                 (beforeTextChanged [this _ _ _ _])
                                 (onTextChanged [this, s, start, before, count]
                                   (on-text-change (.toString s) start before count)))))

(declare ^android.widget.LinearLayout mylayout)

(def main-layout [:linear-layout {:orientation :vertical, :id-holder true}
                  [:edit-text {:hint "Event name" :id ::name :on-text-change (fn [text _ _ _])}]
                  [:edit-text {:hint "Event location" :id ::location}]])

(defactivity MainActivity
  :def a
  :on-create
  (fn [this bundle]
    (on-ui
     (set-content-view! a
      (make-ui main-layout)))))

产生的错误:

main$eval1159$fn__160.invoke(NO_SOURCE_FILE:4)的java.lang.NoSuchMethodException:找不到main$fn__153的方法.SetOnTextChange )

有没有人遇到过类似的问题,或者知道我做错了什么?谢谢您的建议。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-23 20:34:30

我忘了在文档中提到,在定义了一个特性之后,您还应该将它注册为小部件类型。

代码语言:javascript
复制
(neko.ui.mapping/add-trait! :edit-text :on-text-change)

谢谢你指出这一点,我现在要更新文档。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24919971

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档