我在我的应用程序中有多个TextViews,我已经在它们上实现了OnFocusChangeListener和OnClickListener,但我注意到OnFocusChangeListener阻止了OnClickListener ..请告诉我是否有任何解决方法来避免这种情况,因为我必须实现它们。
channelMenu.setOnFocusChangeListener(new View.OnFocusChangeListener() {
@Override
public void onFocusChange(View view, boolean b) {
//Toast.makeText(getActivity(),"changing Focus",2000).show();
if (b) {
channelMenu.setShadowLayer(GLOW, 0f, 0f, Color.WHITE);
mGroupCallback.OnGroupSelected(channelMenu.getText().toString());
} else if (!b) {
channelMenu.setShadowLayer(DIM, 0f, 0f, Color.WHITE);
}
}
});
channelMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (!channelMenuExpanded) {
if(!ischannelSubMenuCreated){
createChannelSubMenu();
channelSubmenusContainer.setVisibility(View.VISIBLE);
channelMenuExpanded = true;
}else if(ischannelSubMenuCreated){
channelSubmenusContainer.setVisibility(View.VISIBLE);
channelMenuExpanded = true;
}
} else {
channelSubmenusContainer.setVisibility(View.GONE);
channelMenuExpanded = false;
}
mGroupCallback.OnGroupSelected(channelMenu.getText().toString());
}
});
答案 0 :(得分:0)
尝试使用触控侦听器,而不是点击侦听器。
tv.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if(event.getAction()==MotionEvent.ACTION_UP){
//Call your click method.
return true.
}
return false;
}
});
修改上述代码以满足您的需求。