[英]how to setOnClickListener in TextInputLayout
ttilLastDate = (TextInputLayout) view.findViewById(R.id.tilLastDate);
tilLastDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.v("PublishTask","has click");
}
});
why the OnClickListener don't work? 为什么OnClickListener不起作用?
I faced the same issue and my solution was to use the setOnFocusChangeListener on the EditText inside the TextInputLayout. 我遇到了同样的问题,我的解决方案是在TextInputLayout内的EditText上使用setOnFocusChangeListener 。
This is an example using ButterKnife . 这是使用ButterKnife的一个例子。
The Layout: 布局:
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<android.support.design.widget.TextInputEditText
android:id="@+id/edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
The listener: 听众:
@OnFocusChange(R.id.edit_text)
public void actionOnEditText(View view, boolean hasFocus) {
if (hasFocus)
yourClickMethod();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.