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
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.
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 OK, so the problem goes away if I comment out the line:
setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1], x, getCompoundDrawables()[3]);
I tried posting this as a runnable to the view's UI queue but no text shows up.
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 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 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.
Something like this:
The red line delimits the Edittext from the ImageButton. It now works on 4.3