Why does this crashes? Delete an element in a scrollview

jmon

Well-Known Member
Licensed User
Longtime User
[HELP!] Delete an element in a scrollview Force Close

Hello,

:sign0085:

I am trying to delete an element in a scrollview. I also want an animation when I delete it. The way I do it now, is triggering the animation before the delete, then when the animation is finished, I update the scrollview by removing all views it contains and the refilling it.

But it crashes.... (Force Close)

Could you please tell me what am I doing wrong? I attach the file with this message.

To replicate the crash: Long click on an item in the list.


This is the error I get:

B4X:
java.lang.NullPointerException
   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1374)
   at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
   at android.view.View.draw(View.java:6845)
   at android.widget.FrameLayout.draw(FrameLayout.java:352)
   at android.view.ViewGroup.drawChild(ViewGroup.java:1648)
   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
   at android.view.ViewGroup.drawChild(ViewGroup.java:1646)
   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
   at android.view.View.draw(View.java:6742)
   at android.widget.FrameLayout.draw(FrameLayout.java:352)
   at android.view.ViewGroup.drawChild(ViewGroup.java:1648)
   at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1375)
   at android.view.View.draw(View.java:6742)
   at android.widget.FrameLayout.draw(FrameLayout.java:352)
   at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1872)
   at android.view.ViewRoot.draw(ViewRoot.java:1422)
   at android.view.ViewRoot.performTraversals(ViewRoot.java:1167)
   at android.view.ViewRoot.handleMessage(ViewRoot.java:1744)
   at android.os.Handler.dispatchMessage(Handler.java:99)
   at android.os.Looper.loop(Looper.java:144)
   at android.app.ActivityThread.main(ActivityThread.java:4937)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:521)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   at dalvik.system.NativeStart.main(Native Method)
Regards
 

Attachments

  • test.zip
    6.9 KB · Views: 136
Last edited:

jmon

Well-Known Member
Licensed User
Longtime User
I added a Timer and moved the FillList routine from AnimDelete_AnimationEnd to Timer1_Tick and it works.

Best regards.

Thank you,

Ok it works, but I can still see the panel coming back to original position for a quick moment. What is the correct way to do this effect?

I guess it is not possible to remove views during the animation finished event.
 
Upvote 0

jmon

Well-Known Member
Licensed User
Longtime User
Actually it can be done like this file I linked, but It's not very clean. Maybe that's the way it's supposed to be done?

I added
B4X:
Dim PANELANIMATED As Panel
in the globals

B4X:
PANELANIMATED = pnl
in "itemSelected_LongClick"

And
B4X:
PANELANIMATED.Visible = False
in "AnimDelete_AnimationEnd"
 

Attachments

  • test_2.zip
    7 KB · Views: 155
Upvote 0
Top