2016-04-06 32 views
3
ttilLastDate = (TextInputLayout) view.findViewById(R.id.tilLastDate); 
tilLastDate.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Log.v("PublishTask","has click"); 
      } 
     }); 

なぜOnClickListenerが機能しないのですか?TextInputLayoutでOnClickListenerを設定する方法

+0

は、XMLもらえますか? –

+0

setOnClickListenerではなくsetOnTouchListenerを使用してみてください。もう一度考えると、あなたのTextInputLayoutでandroid:clickable = "true"を設定していますか? –

+0

2回目のクリック時に動作するかどうか確認してください – Mann

答えて

0

私は同じ問題に直面しました。私の解決策はTextInputLayout内のEditTextにsetOnFocusChangeListenerを使用することでした。

これはButterKnifeを使用した例です。

レイアウト:

    <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> 

リスナー:TextInputLayoutがどこにある

@OnFocusChange(R.id.edit_text) 
public void actionOnEditText(View view, boolean hasFocus) { 
    if (hasFocus) 
     yourClickMethod(); 
} 
関連する問題