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

state_enabled 状态会影响click事件 #6

Open
NickTet opened this issue Sep 5, 2018 · 4 comments
Open

state_enabled 状态会影响click事件 #6

NickTet opened this issue Sep 5, 2018 · 4 comments

Comments

@NickTet
Copy link

NickTet commented Sep 5, 2018

state_enabled 状态会影响click事件

@NickTet
Copy link
Author

NickTet commented Sep 5, 2018

@OverRide
public void into(View view) {
//TextView等view默认没有点击事件,所以针对view初始化点击事件
view.setOnClickListener(null);
view.setBackground(createDrawableSelector());
if (isSelectorTextColor) {
try {
int[] colors = new int[]{mSelectTextColor, mNormalTextColor};
int[][] states = new int[2][];
states[0] = new int[]{state};
states[1] = new int[]{-state};
((TextView) view).setTextColor(new ColorStateList(states, colors));
} catch (Exception e) {
e.printStackTrace();
throw new ExceptionInInitializerError("设置字体颜色选择器(Selector)请传入TextView(或者TextView的子类,比如Button)!!!");
}
}
}
请问一下为什么into(view)的时候要把listener设置为null,这样butterknifie的点击事件就没用了

@LiangLuDev
Copy link
Owner

@NickTet 感谢反馈 这个是因为设置Button之外View的selector 默认是没有触摸事件的。这个我后面更新兼容一下。

@wss991
Copy link

wss991 commented Sep 18, 2018

view.setOnClickListener(null); 个人觉得没必要加这行代码,如果加上了就出现下面情况
比如一个view先设置.setOnClickListener,然后再设置shape 此时点击事件就会无效。

@LiangLuDev
Copy link
Owner

@wang869755676 这个已经有的新的想法,后面会更新

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

3 participants