Skip to content

Commit 0507acd

Browse files
committed
working example
1 parent 7adc5f8 commit 0507acd

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

Diff for: project.clj

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
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

Diff for: src/clojure/com/doppioslash/androidtut/main.clj

+29-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
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)))))

0 commit comments

Comments
 (0)