butterknife

Butterknife does not create anything in .apt_generated directory

心不动则不痛 提交于 2019-12-11 08:49:42
问题 I am trying to use Butterknife for injection, but I do not see any classes generated in the .apt_generated directory. I am using eclipse Kepler (service release 2) , enabled annotation processing in my project properties and defined the butterknife-5.0.0.jar as the annotation processor in the factory path. I have 2 views injected into a fragment for testing, and when I clean the project it is built but nothing is generated. Checking the log file and the error_log view I don't see anything

Exposing Member Variables with ButterKnife

僤鯓⒐⒋嵵緔 提交于 2019-12-11 00:32:11
问题 Curious question, I'm using ButterKnife and I just discovered you can't use in private methods because ButterKnife creates classes that use them. Doesn't that violates the principle of encapsulation? I mean, then your variables will be exposed to other classes as well, no? 回答1: You are totally right, using Butterknife violates the principle of encapsulation. Butterknife uses its own generated code to perform view look-ups. And those look-ups are done in separate class(-es) hence the fields

Butterknife 8.4.0 does not find views after re-running the app. It gets a NullPointerException

二次信任 提交于 2019-12-10 12:30:08
问题 After re-running the app in Android Studio Butterknife.bind(this) does not find the views anymore. The only reliable solution I found so far is by Cleaning/Rebuilding Project and run it again. Then it finds the views again until the next re-run. This is incredibly annoying so far and takes a minimum of two minutes for a rebuild. I have the following build.gradle android { compileSdkVersion 24 buildToolsVersion "25.0.0" defaultConfig { applicationId "xx" minSdkVersion 21 targetSdkVersion 24

关于模块化注意问题

纵饮孤独 提交于 2019-12-10 09:10:47
模块化注意问题链接 这篇文章对模块化中的组件化说的很详细了,另外记录一下经常发生的问题: 模块化 某个library module R文件全部爆红无法编译; 因为模块化后, library中的R文件和application不是一样的,library的R文件不是静态常量; 并且还有一个问题就是 有多个R文件,比如kit library中一个基类使用了layout的R文件属于kit的,而xx library继承了这个基类使用的R文件又是另一个R文件,使用ButterKnife之类的框架可能会产生冲突; 解决方案有下面几种: 重新一个Gradle插件,生成一个R2.java文件,这个文件中各个id都是静态常量,这样就可以正常使用了。(ButterKnife就是使用此方式,但是个人使用感觉成本很高;) 使用Android系统提供的最原始的方式,直接用findViewById以及setOnClickListener方式。(这个可以,但是模块化项目就不推荐使用ButterKnife了) 设置项目支持Databinding,然后使用Binding中的对象,但是会增加不少方法数,同时Databinding也会有编译问题和学习成本,但是这些也是小问题,个人觉的问题不大。 来源: CSDN 作者: MrJarvisDong 链接: https://blog.csdn.net/MrJarvisDong

What is the difference between `@Bind` and `@BindView` in butterknife?

只愿长相守 提交于 2019-12-10 02:38:17
问题 I Just started using butterknife. In the project, colleagues using butterknife, version is 7.0.0. I saw him write @Bind(R.id.tv_name) . But I see butterknife official website butterknife version is 8.0.1, syntax is @BindView(R.id.tv_name) Is syntax changed ? or both can be used ? or something else ? What is the difference between them ? I not find the answer on the Internet I hope everyone's help, thx ! 回答1: Yup, the syntax changed in the version 8.0. You can check the changelog here: https:/

ButterKnife findByID method is deprecated in version 8.8.0

落花浮王杯 提交于 2019-12-10 01:54:47
问题 Hi I have just updated ButterKnife library version 8.7.0 to 8.8.0 compile 'com.jakewharton:butterknife:8.8.0' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.0' and found that: findById(view, id); is deprecated, why? what method to use instead? but when reverting version to 8.7.0 (or earlier) deprecated warning disappears. compileSdkVersion 25 buildToolsVersion "25.0.3" defaultConfig { applicationId "com.some.app" minSdkVersion 21 targetSdkVersion 25 ... 回答1: Per the change log:

Android 2019最新面试实战总结

℡╲_俬逩灬. 提交于 2019-12-09 10:24:49
Android: 今日头条屏幕适配的原理? 1:首先计算出 density,计算公式:当前设备屏幕总宽度(单位为像素)/ 设计图总宽度(单位为 dp) = densitydensity 的意思就是 1 dp 占当前设备多少像素计算density 的原因:在布局文件中填写的是什么单位,最后都会被转化为 px,系统就是通过上面的方法,将你在项目中任何地方填写的单位都转换为 px 但是,今日头条适配方案默认项目中只能以高或宽中的一个作为基准,来进行适配 简述Android中的加固和使用平台? 加固:防止代码反编译,提高代码安全性 加固三方平台,梆梆安全,360加固,爱加密等 区别:梆梆安全,360加固看不到项目中的类,爱加密看的到Java类,单看不到里面的方法实现体,效果比前面差一点点 加固的底层原理:第三方加固的应用会生成一个Apk,然后把你的APK读取出来,在封装到这个第三方应用的APK里面. 如何对APK瘦身? 1)使用混淆, 2)开启shrinkResourse(shrink-收缩),会将没有用到的图片变成一个像素点 3)删除无用的语言资源(删除国际化文件) 4)对于非透明的大图,使用JPG(没有透明度信息),代替PNG格式 5)使用tinypng进行图片压缩 6)使用webp图片格式,进一步压缩图片资源 7)使用第三方包时把用到的代码加到项目中来,避免引用整一个第三方库

Butterknife is unable to bind inside my Adapter Class

梦想的初衷 提交于 2019-12-09 08:10:48
问题 I have an Adapter that draws the layouts for my Navigation Drawer. My navigation drawer contains two inner xml files: One being the Header and the other being the Row . I draw these out in a single adapter, but when I'm trying to setText() on my header, I get failure to bind. Here is my adapter class: public class DrawerAdapter extends RecyclerView.Adapter<DrawerAdapter.ViewHolder> { private static final int HEADER_TYPE = 0; private static final int ROW_TYPE = 1; private static Context

Geeting null when i use BindView in Butterknife

人走茶凉 提交于 2019-12-09 07:13:36
问题 Here my topActivity which extend BaseActivity activity_top.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="schemas.android.com/apk/res/android"; android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <View android:id="@+id/activity_top_group_area1" android:layout_width="wrap_content" android:layout_height="match_parent"/> </LinearLayout> TopActivity.java public class TopActivity extends BaseActivity { @BindView(R.id

Butterknife does not work with Include tag

十年热恋 提交于 2019-12-08 19:23:21
问题 I have a CoordinatorLayout where I have my Button: <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_gravity="bottom|end"> <android.support.design.widget.FloatingActionButton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity=