ClearableEditText - requestLayout()不当呼吁的Andr​​oid 4.3 [英] ClearableEditText - requestLayout() improperly called on Android 4.3

查看:370
本文介绍了ClearableEditText - requestLayout()不当呼吁的Andr​​oid 4.3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我实现<一个href=\"https://github.com/yanchenko/droidparts/blob/develop/droidparts/src/org/droidparts/widget/ClearableEditText.java\"相对=nofollow> ClearableEdittext 和它完美的作品除了在4.3哪里logcat的洪水我:

I implemented ClearableEdittext and it works perfectly except on 4.3 where the logcat floods me with:

W/View(16611): requestLayout() improperly called by com.[myPackage].ui.widgets.ClearableEditText{42233dd0 VFED..CL .F....ID 0,0-708,88 #7f050127 app:id/SearchEdittext} during layout: running second layout pass
W/View(16611): requestLayout() improperly called by com.[myPackage].ui.widgets.ClearableEditText{42233dd0 VFED..CL .F....ID 0,0-708,88 #7f050127 app:id/SearchEdittext} during layout: running second layout pass
W/View(16611): requestLayout() improperly called by com.[myPackage].ui.widgets.ClearableEditText{42233dd0 VFED..CL .F...... 0,0-708,88 #7f050127 app:id/SearchEdittext} during second layout pass: posting in next frame

和在EditText上打字的时候没有文字显示出来。这将启动充斥还logcat中后,用户界面​​是渐冻除了软键盘。

and when typing in the edittext no text shows up. Also after this starts flooding the logcat, the UI is getting frozen except the soft keyboard.

找不到在internetz有这方面的信息。和 requestLayout()必须内EDITTEXT / TextView的类名为原因我从来没有称呼它。
难道你们有谁知道如何解决这一问题还是什么原因造成的错误?

Cannot find any info on this on the internetz. AndrequestLayout() must be called inside Edittext/Textview class cause I never call it. Do anyone of you know how to fix this or what is causing the bug?

EDIT1 确定,所以这个问题消失,如果我注释掉行:

EDIT1 OK, so the problem goes away if I comment out the line:

setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1], x, getCompoundDrawables()[3]);

我试过张贴这是一个可运行的视图的UI队列中,但没有文字显示出来。

I tried posting this as a runnable to the view's UI queue but no text shows up.

EDIT2 我见过一个Android的视频开发商解释说,一些递归期间 onLayout 发生,但再一次,我只是继承的EditText

EDIT2 I have seen this video of an Android Developer explaining that something recursive is happening during onLayout, but once again, I merely subclass EditText.

EDIT3 我也试过放弃该化合物可绘制,并使用另一个的ImageView 之上的的EditText 但它是与布局上的 EDITTEXT 我相信...递归调用仍在进行之中的顶部绘制的东西时,其阻塞UI经过。不知道下一个尝试什么...... 4.3 SUX

EDIT3 I also tried discarding the compound drawable and using another ImageView on top of the EditText but it has something to do with the layout passes when drawing something on top of the Edittext I believe... the recursive call is still happening and its blocking the UI. Don't know what to try next... 4.3 sux

EDIT4 我结束了使用线性布局,水平方向和定制9补丁可绘制的组件的背景。在布局我有我的自定义9patch博伽正常的EditText,然后用另一个定制的ImageButton的9patch博伽梵歌。

EDIT4 I ended up using a linear layout with horizontal orientation and custom 9 patch drawables for the background of the components. In the layout I have a normal edittext with my custom 9patch Bg and then an ImageButton with another custom 9patch Bg.

事情是这样的:

红线划定从的ImageButton的EDITTEXT。现在它工作在4.3

The red line delimits the Edittext from the ImageButton. It now works on 4.3

推荐答案

一个有点晚respons,但我只是有一个相关的问题与ClearableEditText组件。

A bit late respons, but I just had a related issue with the ClearableEditText component.

看来,由于compounddrawables的setClearIconVisible()的变化,聚焦状态事件的一个永恒的循环被触发。

It seems that, due to the change of compounddrawables in setClearIconVisible(), an eternal loop of onfocus events are triggered.

我改变了setClearIconVisible只改变绘如果有任何真正的变化。

I changed the setClearIconVisible to only change the drawable if there are any real change.

   protected void setClearIconVisible(boolean visible) {
        boolean wasVisible = getCompoundDrawables()[2] != null;
        if(wasVisible == visible) return;

        setCompoundDrawables(oldDrawables[0], oldDrawables[1], x, oldDrawables[3]);
        setCompoundDrawablePadding(oldPadding);
    }

这是固定的键盘没有重现我的问题。中的onfocus事件永恒的循环不会做任何人都没有好处。它还添加了新一轮的布局和focusedChanged,所以有可能是一个更聪明的解决了这个。我很好与一个额外的回合,寿。

That fixed my issue with the keyboard not reappearing. An eternal loop of onfocus-events won't do anyone any good. It still adds another round of layout and focusedChanged, so there might be a more clever solution to this. I'm fine with one extra round, tho.

我也发拉请求开发商, https://github.com/ yanchenko / droidparts /拉/ 31

I've also sent a pull request to the developer, https://github.com/yanchenko/droidparts/pull/31.

这篇关于ClearableEditText - requestLayout()不当呼吁的Andr​​oid 4.3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆