1

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 が見つかりませんでした

誰かが同様の問題を経験したか、私が間違っていることを理解しましたか? ご提案いただきありがとうございます。

4

1 に答える 1

1

トレイトを定義した後、それをウィジェット タイプにも登録する必要があることをドキュメントで言及するのを忘れていました。

(neko.ui.mapping/add-trait! :edit-text :on-text-change)

ご指摘ありがとうございます。今すぐドキュメントを更新します。

于 2014-07-23T20:34:30.693 に答える