[android-developers] Re: Updating one view also causes another view to update
Any help on this issue is greatly appreciated. Mihai Fonoage On Oct 29, 3:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: Hello everyone, I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Thank you! Mihai Fonoage --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Mihai Fonoage wrote: Any help on this issue is greatly appreciated. Your question cannot be answered in the abstract. You need to find this out for yourself. Put a breakpoint or dump a stack trace in onDraw() of your second view. Figure out from there what is triggering it. If I had to guess, it is being triggered somehow through whatever layout contains both your view and the Chronometer. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Development Wiki: http://wiki.andmob.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Hi Mark, The stack trace is as follows: W/System.err( 769): java.lang.Throwable: stack dump W/System.err( 769):at java.lang.Thread.dumpStack(Thread.java:610) W/System.err( 769):at package_name.SecondView.onDraw(SecondView .java:381) W/System.err( 769):at android.view.View.draw(View.java:6274) W/System.err( 769):at android.view.ViewGroup.drawChild (ViewGroup.java:1526) W/System.err( 769):at android.view.ViewGroup.dispatchDraw (ViewGroup.java:1256) W/System.err( 769):at android.view.ViewGroup.drawChild (ViewGroup.java:1524) W/System.err( 769):at android.view.ViewGroup.dispatchDraw (ViewGroup.java:1256) W/System.err( 769):at android.view.View.draw(View.java:6277) W/System.err( 769):at android.widget.FrameLayout.draw (FrameLayout.java:352) W/System.err( 769):at android.view.ViewGroup.drawChild (ViewGroup.java:1526) W/System.err( 769):at android.view.ViewGroup.dispatchDraw (ViewGroup.java:1256) W/System.err( 769):at android.view.ViewGroup.drawChild (ViewGroup.java:1524) W/System.err( 769):at android.view.ViewGroup.dispatchDraw (ViewGroup.java:1256) W/System.err( 769):at android.view.View.draw(View.java:6277) W/System.err( 769):at android.widget.FrameLayout.draw (FrameLayout.java:352) W/System.err( 769):at com.android.internal.policy.impl.PhoneWindow $DecorView.draw(Pho neWindow.java:1883) W/System.err( 769):at android.view.ViewRoot.draw(ViewRoot.java: 1332) W/System.err( 769):at android.view.ViewRoot.performTraversals (ViewRoot.java:1097) W/System.err( 769):at android.view.ViewRoot.handleMessage (ViewRoot.java:1613) W/System.err( 769):at android.os.Handler.dispatchMessage (Handler.java:99) W/System.err( 769):at android.os.Looper.loop(Looper.java:123) W/System.err( 769):at android.app.ActivityThread.main (ActivityThread.java:4203) W/System.err( 769):at java.lang.reflect.Method.invokeNative (Native Method) W/System.err( 769):at java.lang.reflect.Method.invoke(Method.java: 521) W/System.err( 769):at com.android.internal.os.ZygoteInit $MethodAndArgsCaller.run(Zygo teInit.java:791) W/System.err( 769):at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:549) W/System.err( 769):at dalvik.system.NativeStart.main(Native Method) I have a LinearLayout that contains the Chronometer (+ some TextViews all in another LinearLayout), and the SecondView view. I guess the problem is that all child views (Chronometer + SecondView) of the root LinearLayout view are updated in case one of its child views (Chronometer) gets updated (there is no concept of partially updating the screen?). Should it be like this. Since I haven't changed anything in my second view, it should not be re-drawn. The problem is that this is out of my control. There is nothing I can do to stop the second view of being re-drawn. Mihai Fonoage On Oct 30, 8:35 am, Mark Murphy mmur...@commonsware.com wrote: Mihai Fonoage wrote: Any help on this issue is greatly appreciated. Your question cannot be answered in the abstract. You need to find this out for yourself. Put a breakpoint or dump a stack trace in onDraw() of your second view. Figure out from there what is triggering it. If I had to guess, it is being triggered somehow through whatever layout contains both your view and the Chronometer. -- Mark Murphy (a Commons Guy)http://commonsware.com|http://twitter.com/commonsguy Android Development Wiki:http://wiki.andmob.org --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
On Oct 29, 7:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Might this be your problem? http://www.curious-creature.org/2009/05/02/drawable-mutations/ String --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Thanks for the link String! I am trying to figure out what Drawable is shared between the Chronometer and my SecondView (which draws some bitmaps), but I cannot come with anything. Looking at my stack trace, there is nothing there to suggest anything similar. I will look more into that, but my feeling is that it might be another (though similar) problem. Mihai Fonoage On Oct 30, 11:22 am, String sterling.ud...@googlemail.com wrote: On Oct 29, 7:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Might this be your problem?http://www.curious-creature.org/2009/05/02/drawable-mutations/ String --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Mihai Fonoage wrote: I have a LinearLayout that contains the Chronometer (+ some TextViews all in another LinearLayout), and the SecondView view. I guess the problem is that all child views (Chronometer + SecondView) of the root LinearLayout view are updated in case one of its child views (Chronometer) gets updated (there is no concept of partially updating the screen?). Should it be like this. Since I haven't changed anything in my second view, it should not be re-drawn. The problem is that this is out of my control. There is nothing I can do to stop the second view of being re-drawn. Why are you worried about this? -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Beginning Android_ from Apress Now Available! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
On Oct 30, 12:36 pm, Mihai Fonoage fonoag...@gmail.com wrote: Any help on this issue is greatly appreciated. Mihai Fonoage On Oct 29, 3:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: Hello everyone, I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Thank you! Mihai Fonoage hi, my guess is that Chronometer when updated can change its size causing parent ViewGroup to re-leyout its children and as a consequence to draw all children pskink --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
On Oct 30, 5:15 pm, skink psk...@gmail.com wrote: On Oct 30, 12:36 pm, Mihai Fonoage fonoag...@gmail.com wrote: Any help on this issue is greatly appreciated. Mihai Fonoage On Oct 29, 3:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: Hello everyone, I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Thank you! Mihai Fonoage hi, my guess is that Chronometer when updated can change its size causing parent ViewGroup to re-leyout its children and as a consequence to draw all children pskink i checked that Chronometer is a TextView so it could be the case. try for testing purposes set both layout_width/layout_height to 'fill_parent' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
@Mark I care because something needs to be drawn if the onDraw method is being called. If there are no actual changes to the view, then this is a waste of resources (probably unnoticeable) and I need to deal with this case specifically, which complicates my application logic a little (here though it is probably my fault - not a perfect design). @skink You are right, there is an issue with the layout, but while I can get it to work and not have onDraw called every second, the views are not displayed as I want to. I will play around with this layout issue some more and see if I can get a fix. Beside all this, I do find it unnecessary; characters representing numbers from 0 to 9 have the same height, so the layout height (which is set to wrap_content) should not change. Mihai Fonoage On Oct 30, 12:25 pm, skink psk...@gmail.com wrote: On Oct 30, 5:15 pm, skink psk...@gmail.com wrote: On Oct 30, 12:36 pm, Mihai Fonoage fonoag...@gmail.com wrote: Any help on this issue is greatly appreciated. Mihai Fonoage On Oct 29, 3:44 pm, Mihai Fonoage fonoag...@gmail.com wrote: Hello everyone, I have two views, one of which is a Chronometer. Whenever the Chronometer gets updated (every second, automatically, after its start () method has been called), the onDraw method of my second view is called. Any way I can stop this from happening? Thank you! Mihai Fonoage hi, my guess is that Chronometer when updated can change its size causing parent ViewGroup to re-leyout its children and as a consequence to draw all children pskink i checked that Chronometer is a TextView so it could be the case. try for testing purposes set both layout_width/layout_height to 'fill_parent' --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Mihai Fonoage wrote: and I need to deal with this case specifically, which complicates my application logic a little (here though it is probably my fault - not a perfect design). Your View should not care about how many times it is drawn. Relying on assumed behavior (e.g., onDraw() is only called in certain scenarios) is not safe. Otherwise, your code may break in future Android releases where your assumption is no longer valid. You are certainly welcome to figure out how to avoid onDraw() unnecessarily, but you really need to implement support for onDraw() occurring when you are not necessarily expecting it. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Android Programming Tutorials_ Version 1.0 In Print! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Updating one view also causes another view to update
Mark Murphy mmur...@commonsware.com wrote: Mihai Fonoage wrote: and I need to deal with this case specifically, which complicates my application logic a little (here though it is probably my fault - not a perfect design). Your View should not care about how many times it is drawn. Relying on assumed behavior (e.g., onDraw() is only called in certain scenarios) is not safe. Otherwise, your code may break in future Android releases where your assumption is no longer valid. You are certainly welcome to figure out how to avoid onDraw() unnecessarily, but you really need to implement support for onDraw() occurring when you are not necessarily expecting it. That is what I ended up doing. I just found everything to be curious to say the least. Thank you all for the feedback! Mihai Fonoage --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---