android listview edittext 焦点冲突,Android - ListView EditText焦点问题

我有EditText,我将ListView作为页脚View使用。我试图访问焦点/失去焦点事件,但由于某种原因,它每次焦点都会发射多次。这里发生了什么?

// 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 );

// ...单键触摸输出,可以打开键盘:

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设置为true的多个事件,但为什么还有falses,触发了Un Clicked日志?

编辑:此外,无论何时上下滚动ListView,将EditText移入和移出视图,它都会调用这些事件。我是否使用了错误的侦听器类型?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值