EditText
のフッターとして使用している がView
ありますListView
。フォーカス イベントにアクセスしようとしていますが、何らかの理由で、フォーカスごとに複数回発生しています。ここで何が起こっているのですか?
// in onCreate
// ...
// the footer
View v = getLayoutInflater().inflate( R.layout.comment_edittext, null );
EditText commentEditText = (EditText)v.findViewById( R.id.comment_edittext );
commentEditText.setOnFocusChangeListener( new OnFocusChangeListener() {
@Override
public void onFocusChange( View v, boolean hasFocus )
{
U.log("View: " + v.getClass().getName().toString() );
if( hasFocus )
{
U.log( "Clicked" );
}
else
{
U.log( "Un Clicked" );
}
}
} );
// add the footer
commentListView.addFooterView( v );
// ...
キーボードを表示する 1 回のタッチの出力は次のとおりです。
04-11 10:22:17.449: E/004 - X(4576): View: android.widget.EditText
04-11 10:22:17.459: E/004 - X(4576): Clicked
04-11 10:22:17.569: E/004 - X(4576): View: android.widget.EditText
04-11 10:22:17.569: E/004 - X(4576): Un Clicked
04-11 10:22:17.569: E/004 - X(4576): View: android.widget.EditText
04-11 10:22:17.569: E/004 - X(4576): Clicked
04-11 10:22:17.689: E/004 - X(4576): View: android.widget.EditText
04-11 10:22:17.689: E/004 - X(4576): Un Clicked
04-11 10:22:17.709: E/004 - X(4576): View: android.widget.EditText
04-11 10:22:17.709: E/004 - X(4576): Clicked
hasFocus
set to を使用して複数のイベントを呼び出していることはある程度理解できますが、ログをトリガーする strue
も存在するのはなぜですか?false
Un Clicked
編集:ListView
さらに、上下にスクロールしEditText
てビューの内外を移動すると、これらのイベントも呼び出されます。おそらく間違ったリスナータイプを使用していますか?