如何使用butterknife
1个回答
2017-09-30
展开全部
androidbutterknifezelezny用法:一,配置butterknifeConfigureyourproject-levelbuild.gradletoincludethe'android-apt'plugin:buildscript{repositories{mavenCentral()}dependencies{classpath'com.neenbedankt.gradle.plugins:android-apt:1.8'}}Then,applythe'android-apt'plugininyourmodule-levelbuild.gradleandaddtheButterKnifedependencies:applyplugin:'android-apt'android{}dependencies{compile'com.jakewharton:butterknife:8.2.1'apt'com.jakewharton:butterknife-compiler:8.2.1'}二,安装ButterKnifeZelezny插件File->Seting->Plugins->BrowserResponsities->ButterknifeZelezny三,使用插件时xml中的布局写法publicclassMainListActivityextendsAppCompatActivity{@BindView(R.id.marquee_tv)TextViewmMarqueeTv;@BindView(R.id.more_tv)TextViewmMoreTv;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_main_list);ButterKnife.bind(this);}@OnClick({R.id.marquee_tv,R.id.more_tv})publicvoidonClick(Viewview){switch(view.getId()){caseR.id.marquee_tv:break;caseR.id.more_tv:break;}}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询