Aspsine / Aspsine/EditTextInListView

光标闪烁和焦点不再预期位置

Open
#6 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
114
Forks
35
PR merge metrics
No merged PRs in 30d

Description

我的手机魅族M2(魅蓝2)
情况如果,一个activity头部有2个EditText,ListView的item里面有2个EdiTetxt。
按照你的代码,第一次点击没有任何问题。但是第2次就有了,然后没双数次点击就会出现,
我原本想在ListView的某一个EditText获取焦点,但是他的焦点会莫名在跳转到头部的第一个EditText去。
最后我修改了代码

> fdpq.setOnTouchListener(new View.OnTouchListener() {
> @Override
> public boolean onTouch(View v, MotionEvent event) {
> if (event.getAction() == MotionEvent.ACTION_UP) {
> new Handler().postDelayed(new Runnable() {
> @Override
> public void run() {
> boolean fdpqFocus = t.fdpqFocus;
> checkFdpq(position);
> if (!fdpqFocus || !fdpq.isFocused()) {
> fdpq.requestFocus();
> fdpq.onWindowFocusChanged(true);
> CharSequence text = inputMap.get(position+"_fdpq");
> ((EditText)fdpq).setSelection(StringUtils.isNullOrEmpty(text) ? 0 : text.length());
> }
> }
> }, 200);
> }
> return false;
> }
> });

这样就可以了。

> CharSequence text = inputMap.get(position+"_fdpq");
> ((EditText)fdpq).setSelection(StringUtils.isNullOrEmpty(text) ? 0 : text.length());

这2句代码,是处理当EditText正常获取焦点的时候他的光标在0的位置。

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.