我开始阅读Neko的教程,我想创造自己的特质。如所述,我一直在关注 neko 上的文档处所述,但它不断产生错误。
更加具体:
; 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)))))
产生的错误:
java.lang.NoSuchMethodException:在 main$eval1159$fn__160.invoke(NO_SOURCE_FILE:4) 找不到参数 main$fn__153) 的方法 .SetOnTextChange
有没有人遇到过类似的问题或知道我做错了什么?在此先感谢您的任何建议。