<think>我们需要移除ButterKnife库,因此需要手动绑定视图,并删除所有ButterKnife相关的注解和代码。
具体步骤如下:
1. 删除所有ButterKnife的导入语句。
2. 删除`ButterKnife.bind(this)`调用。
3. 删除`@BindView`注解。
4. 手动通过`findViewById`来绑定视图。
5. 调整初始化方法,确保在inflate布局后立即绑定视图。
修改后的代码:</think>以下是移除 ButterKnife 库后的完整代码,所有视图绑定都改为手动实现:
```java
package org.autojs.autojs.ui.widget;
import android.content.Context;
import android.graphics.drawable.GradientDrawable;
import androidx.annotation.AttrRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import com.makeramen.roundedimageview.RoundedImageView;
import com.retesla.autoxjs.R;
/**
* Created by 婷 on 2017/9/29.
*/
public class AvatarView extends FrameLayout {
private TextView mIconText;
private RoundedImageView mIcon;
private GradientDrawable mIconTextBackground;
public AvatarView(@NonNull Context context) {
super(context);
init();
}
public AvatarView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
public AvatarView(@NonNull Context context, @Nullable AttributeSet attrs, @AttrRes int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init()
public void setIcon(int resId)
// 添加更多功能方法
public void setText(String text)
public void setTextColor(int color)
public void setBackgroundColor(int color)
}
}
```