问题描述
public class LoginActivity extends AppCompatActivity {
@BindViews(value = {R.id.logo, R.id.first, R.id.second, R.id.last})
protected List<ImageView> sharedElements;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
ButterKnife.bind(this);
@BindViews({R.id.pager)
@BindViews(R.id.scrolling_background)
final AnimatedViewPager pager = ButterKnife.findById(this, R.id.pager);
final ImageView background = ButterKnife.findById(this, R.id.scrolling_background);
int[] screenSize = screenSize();
for (ImageView element : sharedElements) {
@ColorRes int color = element.getId() != R.id.logo ? R.color.white_transparent : R.color.color_logo_log_in;
DrawableCompat.setTint(element.getDrawable(), ContextCompat.getColor(this, color));
}
授权片段
{
public abstract class AuthFragment extends Fragment {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
protected Callback callback;
@BindView(R.id.caption)
protected VerticalTextView caption;
@BindView(R.id.root)
protected ViewGroup parent;
protected boolean lock;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View root = inflater.inflate(authLayout(), container, false);
ButterKnife.bind(this, root);
KeyboardVisibilityEvent.setEventListener(getActivity(), isOpen -> {
callback.scale(isOpen);
if (!isOpen) {
clearFocus();
}
});
return root;
}
public void setCallback(@NonNull Callback callback) {
this.callback = callback;
}
@LayoutRes
public abstract int authLayout();
public abstract void fold();
public abstract void clearFocus();
@OnClick(R.id.root)
public void unfold() {
if (!lock) {
caption.setVerticalText(false);
caption.requestLayout();
Rotate transition = new Rotate();
transition.setStartAngle(-90f);
transition.setEndAngle(0f);
transition.addTarget(caption);
TransitionSet set = new TransitionSet();
set.setDuration(getResources().getInteger(R.integer.duration));
ChangeBounds changeBounds = new ChangeBounds();
set.addTransition(changeBounds);
set.addTransition(transition);
TextSizeTransition sizeTransition = new TextSizeTransition();
sizeTransition.addTarget(caption);
set.addTransition(sizeTransition);
set.setOrdering(TransitionSet.ORDERING_TOGETHER);
caption.post(() -> {
TransitionManager.beginDelayedTransition(parent, set);
}
请帮我用 butterknife 修复这个错误.findbyid 也不可用无法使用 bindview 请帮助文档或您的代码.所以这就是 authFragment 在按照 GermliShx 的建议进行一些更改之后,这些错误可能是我的实现错误,所以请帮助我.这是登录页面,带有一些动画 idk y butterknife 正在制造问题.我尝试解决它但没有运气这个错误是由于黄油刀的错误实现所以请帮助我
pls help me fix this error with butterknife . findbyid isnt also not available not able to use bindview pls help out with documentation or your code. so thats the authFragment now after some changes as suggested by GermliShx these error came maybe it my implementation error so pls help me out. this is the login page with some animation idk y butterknife is creating problem her . i tried solving it but no luck this error is due to wrong implementation of butter knife so pls hel me out
推荐答案
先去掉这个:
@BindViews({R.id.pager)
@BindViews(R.id.scrolling_background)
...
final AnimatedViewPager pager = ButterKnife.findById(this, R.id.pager);
final ImageView background = ButterKnife.findById(this, R.id.scrolling_background);
第二次添加:
public class LoginActivity extends AppCompatActivity {
...
//binding is declared outside OnCreate / any other function
//your case
@BindView(R.id.pager)
AnimatedViewPager pager;
@BindView(R.id.scrolling_background)
ImageView background ;
..
//then in code just use declared pager and background when needed
@Override
protected void onCreate(Bundle savedInstanceState) {
background .setColorFilter (R.color.black); //example
}
应该可以,但我不确定 AnimatedViewPager 是什么.
Should work, but I am not sure what AnimatedViewPager is.
它也可能显示Resource IDs will be non-final in Android Gradle Plugin version 7.0,避免将它们用作注释属性
警告,但您可以取消它.
It also may show Resource IDs will be non-final in Android Gradle Plugin version 7.0, avoid using them as annotation attributes
warning, but you can just suppress it.
尝试回复情况如何.
这篇关于无法在局部变量“@BindViews"中使用不适用于局部变量黄油刀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!