为什么我需要Android数据绑定中的# query for template file with one slide
TMPLFILE = SLIDE_TEMPLATE_FILE
rsp = DRIVE.files().list(q="name='%s'" % TMPLFILE).execute().get('files')[0]
# copy template file
DATA = {'name': 'Google Drive & Slides API template DEMO'}
DECK_ID = DRIVE.files().copy(body=DATA, fileId=rsp['id']).execute().get('id')
# create 2 more (1 title-only & 1 blank) slides in copied file
reqs = [
{'createSlide': {'slideLayoutReference': {'predefinedLayout': 'TITLE_ONLY'}}},
{'createSlide': {'slideLayoutReference': {'predefinedLayout': 'BLANK'}}},
]
SLIDES.presentations().batchUpdate(body={'requests': reqs},
presentationId=DECK_ID).execute()
,我们应该何时使用它?
答案 0 :(得分:3)
如果你想到DataBinding实际上在做什么,那么Inverse
这个词真的是说你需要知道的一切。
如果您为Layout
启用了DataBinding,则可以将其视为两件事:
View
(Views
中包含的所有<layout></layout>
)Model
(<data></data>
中包含的所有变量) 常规数据绑定可确保Model
中的更改在View
中产生影响。它由@{expression}
调用。
反向数据绑定可确保View
中的更改在Model
中产生影响。它由@={expression}
调用(此处=
字符必不可少)。
如果您认为在View
中进行更改的方式有哪些,可以是:
TextView
中的文字)RadioGroup
)其中一些默认情况下已启用,而其他人则需要编写自定义InverseBindingAdapter
。更多关于here。
如果您仍需要有关该主题的更多信息,建议您观看Google I/O 2016 presentation on Advanced DataBinding。