             [neko.context :as context]
             [neko.listeners.view :as view-listeners])
   (:use [neko.-utils :only [memoized]])
-  (:import [android.widget LinearLayout$LayoutParams]
+  (:import [android.widget LinearLayout$LayoutParams TextView]
            [android.view View ViewGroup$LayoutParams]
            android.util.TypedValue
            java.util.HashMap))

  (def foo (make-ui [:linear-layout {:id-holder true}
                     [:button {:id ::abutton}]]))
  (::abutton (.getTag foo)) => internal Button wdgect."
  (fn [wdg _ __]
    (.setTag ^View wdg (HashMap.))
    {:options-fn #(assoc % :id-holder wdg)}))

(deftrait :id
  "Takes `:id` attribute, which should be a keyword, and stores the
  current widget in ID-holder's tag (see docs for `:id-holder`
  trait)."
  (fn [wdg {:keys [id]} {:keys [^View id-holder]}]
    (if (nil? id-holder)
      (throw (Exception. ":id trait: id-holder is undefined in this UI tree."))
      (.put ^HashMap (.getTag id-holder) id wdg))))

  (let [[docstring args] (if (string? (first args))
                           [(first args) (next args)]
                           [nil args])
        [match-pred args] (if-not (vector? (first args))
                            [(first args) (next args)]
                            [name args])
        codegen-body args
        dissoc-fn `(fn [a#] (dissoc a# ~name))]
    `(do
       (alter-meta! #'apply-trait
