Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

自定义Holder,对象错位的问题,需要加静态修饰来解决; #356

Open
HZHAndroid opened this issue Oct 28, 2019 · 0 comments

Comments

@HZHAndroid
Copy link

public class LauncherHolder extends Holder {
private AppCompatImageView mImageView = null;

public LauncherHolder(View itemView) {
    super(itemView);
}

@Override
protected void initView(View itemView) {
    mImageView = itemView.findViewById(R.id.picIv);
    Log.e("JKSDJF", mImageView + "   " + this);
}

@Override
public void updateUI(Integer data) {
    try {
        Log.e("JKSDJF", data + "");
        Log.e("JKSDJF", mImageView + "    " + this);
        if (data != null && mImageView != null) {
            mImageView.setImageResource(data);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

}

1、执行【initView】方法的时候,Log.e("JKSDJF", mImageView + " " + this); 打印出来的 mImageView 有值;
2、到了【updateUI】,Log.e("JKSDJF", mImageView + " " + this); 打印出来的 mImageView 为null,而且两次打印的 this 对象有很大概率不是同一个;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant