我无法在android中找到word_en索引。如何才能到达word_en或word_tr1?我使用JSONObject将索引作为String发布,然后我需要获取word_en索引。感谢。
{
post: [
{
word_en: "central heating",
word_tr1: "merkezi ısıtma "
},
{
word_en: "plant",
word_tr1: "bitki "
},
{
word_en: "fireplace",
word_tr1: "şömine "
},
{
word_en: "dining room",
word_tr1: "yemek odası "
},
{
word_en: "downstairs",
word_tr1: "alt kat "
},
{
word_en: "upstairs",
word_tr1: "üst kat "
},
{
word_en: "conversation",
word_tr1: "görüşme "
}
]
}
答案 0 :(得分:0)
(def q-id (atom 0))
(def value-name (atom ""))
(def next-id (atom 0))
(defn create-answer
"Creates a radio button answer"
([question-id answer value name event next-question-id class description]
[:div {:class :control-container}
[:div {:class :control-left}
[:input {:type :radio :value value :name name :class class :data-next next-question-id :on-change (fn [e] (reset! value-name value) (reset! q-id question-id) (reset! next-id next-question-id) (re-frame/dispatch [event e]))}]]
[:div {:class :control-right} answer]
; If there is no description, then do not render the "control-right-description" div
(if-not (clojure.string/blank? description)
[:div {:class :control-right-description} description])
])
([question-id answer value name event next-question-id class]
(create-answer question-id answer value name event next-question-id class ""))
)
(defn display-val
[item]
(if (or (= @next-id (get item :id)) (and (get item :first) (= @next-id 0))) "block" "none")
)
(defn create-block
"Renders a question and the possible answers"
[item]
(if (get item :first)
[:div {:id (str "divQ" (get item :id)) :style {:display (display-val item)}}
[:div
[:p (get item :question)]
(for [answer (get item :answers)]
(create-answer (get item :id) (get answer :answer) (get answer :value) (get answer :name) (get answer :event) (get answer :nextQuestionId) (get answer :className) (get answer :description))
)
]
]
[:div {:id (str "divQ" (get item :id)) :style {:display (display-val item)}}
[:div
[:p (get item :question)]
(for [answer (get item :answers)]
(create-answer (get item :id) (get answer :answer) (get answer :value) (get answer :name) (get answer :event) (get answer :nextQuestionId) (get answer :className) (get answer :description))
)
]
]
)
)
(defn render-questions
"Renders the questions and answers, hiding all but the first question and answer set"
[]
(for [item cfg/questions]
(create-block item)
)
)
(defn main-panel []
(let [name (re-frame/subscribe [:name])]
(fn []
[:div
; Render the questions
(render-questions)
]
)))
(defn handle-buttons-part-one
[db e]
;(js/alert @value-name)
)
(re-frame/reg-event-db :buttons-part-one handle-buttons-part-one)
这应该是一个想法。