目前,如果我想附加绑定,我会
DataBindingUtil.setContentView(this, R.layout.main_activity);
我遇到了需要调用
的自定义第三方活动的麻烦setContentView(R.layout.main_activity);
如何将绑定附加到使用setContentView
答案 0 :(得分:4)
首先需要给你的布局充气,调用/* I don't know if passing 'null' as parent breaks something in your layout, I tested it in
mine and it did work.*/
View rootView = LayoutInflater.from(this).inflate(R.layout.activity_main, null);
setContentView(rootView);
ActivityMainBinding binding = DataBindingUtil.bind(rootView);
并设置数据绑定:
<span id="signature_email"><a class="__cf_email__" href="/cdn-cgi/l/email-protection" data-cfemail="30425f5e70584346515c5c531e535f5d">[email protected]</a><script data-cfhash='f9e31' type="text/javascript">/* <![CDATA[ */!function(t,e,r,n,c,a,p){try{t=document.currentScript||function(){for(t=document.getElementsByTagName('script'),e=t.length;e--;)if(t[e].getAttribute('data-cfhash'))return t[e]}();if(t&&(c=t.previousSibling)){p=t.parentNode;if(a=c.getAttribute('data-cfemail')){for(e='',r='0x'+a.substr(0,2)|0,n=2;a.length-n;n+=2)e+='%'+('0'+('0x'+a.substr(n,2)^r).toString(16)).slice(-2);p.replaceChild(document.createTextNode(decodeURIComponent(e)),c)}p.removeChild(t)}}catch(u){}}()/* ]]> */</script></span></span> <span class="separator">|</span>