具有自定义视图的Crouton:未调用onClickListener(Crouton with custom view: onClickListener not called)
我有一个关于烤面包片的问题:
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,它可以工作。 难道我做错了什么?
I have an issue with crouton:
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); } });If I provide a customView to the make method, the onClickListener is never called. If I use the makeText, it works. Am I doing something wrong?
最满意答案
尚不支持将OnClickListener添加到自定义视图。 处理自定义视图中单击事件的最简单方法Crouton是将OnClickListener直接添加到自定义视图中。
Adding an OnClickListener to a custom view is not yet supported. The easiest way to handle click events within a custom view Crouton is to add the OnClickListener directly to your custom view.
更多推荐
发布评论