我对布鲁顿有意见:
customView = LayoutInflater.from(context).inflate(viewId, null);
if (customView != null) {
TextView title = (TextView) customView.findViewById(R.id.crouton_title);
if (title != null) {
title.setText(titleString);
}
TextView message = (TextView) customView.findViewById(R.id.crouton_message);
if (message != null) {
message.setText(messageString);
}
}
final Crouton crouton = Crouton.make((Activity) context, customView);
crouton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Crouton.hide(crouton);
}
});如果我向make方法提供customView,则永远不会调用onClickListener。如果我使用makeText,它就能工作。我做错了什么吗?
发布于 2013-12-02 17:22:18
还不支持向自定义视图添加OnClickListener。处理自定义视图Crouton中的单击事件的最简单方法是将OnClickListener直接添加到自定义视图中。
https://stackoverflow.com/questions/20330896
复制相似问题