![]() | 1 nicktogo 2016-09-19 11:56:20 +08:00 via iPhone data binding? |
3 yuyu2140 2016-09-19 12:27:44 +08:00 ![]() 咦?怎么跟我这边的需求很像?! 我的解决方案是,每个 textview 加上 tag 属性,例如: <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:tag="name"/> 然后遍历根布局下所有子控件,取出 tag 作为 json 的 key ,取出 textview 的文字作为 json 的 value 即可。 |
4 yuyu2140 2016-09-19 12:28:53 +08:00 上面的是取值的过程,填充的过程是一样的,通过 tag 值遍历填充即可 |
![]() | 6 lawlietxxl 2016-09-19 13:46:26 +08:00 动态添加 textview 可好? |
![]() | 7 rockyou12 2016-09-19 14:55:55 +08:00 databinding 是最好的!连 findviewById 都不同写,也不像 butterknife 还要整一堆注解。 mvvm 大法好!可惜之前用的时候有少许兼容性问题,不然连 retrolambda 也可以扔掉了 |
![]() | 8 iFlicker 2016-09-19 15:29:20 +08:00 DataBinding 看起来很方便 没用过。 不过楼上说有兼容性是指的 5.0 以下么? |
![]() | 9 SorcererXW 2016-09-19 16:13:34 +08:00 via Android TextView[ ] |
![]() | 10 Gehrman OP 设置 tag 这个方法可行,而且正好我不止要填充,还要取值.databinding 看起来需要更多的时间来理解 |