File tree 2 files changed +30
-5
lines changed
src/clojure/com/doppioslash/androidtut
2 files changed +30
-5
lines changed Original file line number Diff line number Diff line change 13
13
:javac-options [" -target" " 1.6" " -source" " 1.6" " -Xlint:-options" ]
14
14
15
15
: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" ]]
18
17
19
18
:plugins [[cider/cider-nrepl " 0.7.0" ]]
20
19
Original file line number Diff line number Diff line change 1
1
(ns com.doppioslash.androidtut.main
2
2
(:use [neko.activity]
3
3
[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 }]])
5
32
6
33
(defactivity com.doppioslash.androidtut.Reader
7
34
:def a
8
35
:on-create
9
36
(fn [this bundle]
10
37
(on-ui
11
38
(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