File tree Expand file tree Collapse file tree
src/clojure/com/doppioslash/androidtut Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 :javac-options [" -target" " 1.6" " -source" " 1.6" " -Xlint:-options" ]
1414
1515 :dependencies [[org.clojure-android/clojure " 1.6.0-RC1" :use-resources true ]
16- [neko/neko " 3.0.1" ]
17- [adamwynne/feedparser-clj " 0.5.2" ]]
16+ [neko/neko " 3.0.1" ]]
1817
1918 :plugins [[cider/cider-nrepl " 0.7.0" ]]
2019
Original file line number Diff line number Diff line change 11(ns com.doppioslash.androidtut.main
22 (:use [neko.activity]
33 [neko.threading :only [on-ui]]
4- [neko.ui :only [make-ui]]))
4+ [neko.ui :only [make-ui config]]))
5+
6+ (declare ^android.widget.LinearLayout mylayout )
7+ (declare add-text )
8+
9+ (def lines (atom " " ))
10+
11+ (defn get-elmt [elmt]
12+ (str (.getText (elmt (.getTag mylayout)))))
13+
14+ (defn set-elmt [elmt s]
15+ (on-ui (config (elmt (.getTag mylayout)) :text s)))
16+
17+ (defn update-ui []
18+ (set-elmt ::lines @lines)
19+ (set-elmt ::edit " " ))
20+
21+ (defn add-text []
22+ (swap! lines str (get-elmt ::edit ) " \n " )
23+ (update-ui ))
24+
25+
26+ (def main-layout [:linear-layout {:orientation :vertical
27+ :id-holder true
28+ :def `mylayout}
29+ [:edit-text {:hint " Write here" ,:id ::edit }]
30+ [:button {:text " Add text" :on-click (fn [_](add-text ))}]
31+ [:text-view {:text @lines,:id ::lines }]])
532
633(defactivity com.doppioslash.androidtut.Reader
734 :def a
835 :on-create
936 (fn [this bundle]
1037 (on-ui
1138 (set-content-view! a
12- (make-ui [:linear-layout {}
13- [:text-view {:text " Hello from Clojure!" }]])))))
39+ (make-ui main-layout)))))
You can’t perform that action at this time.
0 commit comments