我开始学习尼科的教程,我想要创建自己的特性。我一直在跟踪描述这里的关于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)))))产生的错误:
main$eval1159$fn__160.invoke(NO_SOURCE_FILE:4)的java.lang.NoSuchMethodException:找不到main$fn__153的方法.SetOnTextChange )
有没有人遇到过类似的问题,或者知道我做错了什么?谢谢您的建议。
发布于 2014-07-23 20:34:30
我忘了在文档中提到,在定义了一个特性之后,您还应该将它注册为小部件类型。
(neko.ui.mapping/add-trait! :edit-text :on-text-change)谢谢你指出这一点,我现在要更新文档。
https://stackoverflow.com/questions/24919971
复制相似问题