Android Question anyone can help me?

Discussion in 'Android Questions' started by khosrwb, Jul 21, 2015.

  1. khosrwb

    khosrwb Active Member Licensed User

    what is problem in my app?
    when I delete the this code my app worked truly:confused:
    Code:
    For i=0 To 10
        listview1.AddTwoLines(i,i)
    Next
     

    Attached Files:

    • n.zip
      File size:
      25.5 KB
      Views:
      15
  2. ilan

    ilan Expert Licensed User

    What error do you get?

    Can you post the whole code in that sub? (Because i cannot download your file right now)
     
    MarcoRome likes this.
  3. khosrwb

    khosrwb Active Member Licensed User

    excuseme but this program inclouded 3 modules and its large for attach here
     
  4. ilan

    ilan Expert Licensed User

    Dont need the moduls only that sub
     
  5. Beja

    Beja Expert Licensed User

    Next I
     
  6. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Next is fine without the "I"

    @khosrwb : shouldn't ListView1 been Initialized before to fill it ?
     
  7. ilan

    ilan Expert Licensed User


    those lines are ok, it has something to do with the class, i dont have those libs so i cannot not test it.

    btw you should put "if firsttime = true then..." in activity create unless your code will every activity start load 10 new items to your listview
    or you can clear the items before you add new items...
     
  8. ilan

    ilan Expert Licensed User

    views that has been created in designer should not be intialized...
     
    lemonisdead and DonManfred like this.
  9. ilan

    ilan Expert Licensed User

    when i try the code my listview get filled like it should be, only after i slide i get an error (something with class... but again i have not those libs so i removed the LockScreenController lines)

    and i also use b4a 4.3
     
  10. lemonisdead

    lemonisdead Well-Known Member Licensed User

    Damn you are right : didn't saw it was created in the designer
     
    DonManfred likes this.
  11. Cableguy

    Cableguy Expert Licensed User

    actually 0 to 10 will cycle 11 times thus going from 0 to 10 = 11 items
     
  12. ilan

    ilan Expert Licensed User

    you are right, i believe he understood my point ;)
     
  13. Cableguy

    Cableguy Expert Licensed User

    I just mentioned that because i have too many times forgoten than an index begins at 0. And that an array lenght counts the actual amout of items in it, so the last index is length - 1!
     
    RandomCoder and lemonisdead like this.
  14. khosrwb

    khosrwb Active Member Licensed User

    when I run this program and use from them
    show error on line 469 in class module (( ClsSlidingSideBar ))
    and when remove this code from Activity module (( LockScreen )) program worked truly
    Code:
    For i=0 To 10
        listview1.AddTwoLines(i,i)
    Next
    I don't know what is the problem :(
    please help me
     
  15. RandomCoder

    RandomCoder Well-Known Member Licensed User

    Please list the actual error message that you recieve.
     
  16. ilan

    ilan Expert Licensed User

    where can we download that lib to test your code?
     
  17. khosrwb

    khosrwb Active Member Licensed User

    you can download here
     

    Attached Files:

  18. khosrwb

    khosrwb Active Member Licensed User

    on the log show this error :

    LogCat connected to: B4A-Bridge: Sony Ericsson ST18
    --------- beginning of /dev/log/system
    --------- beginning of /dev/log/main
    Installing file.
    PackageAdded: package:com.datasteam.b4a.system.lockscreen.sample
    ** Activity (main) Create, isFirst = true **
    ** Activity (main) Resume **
    ** Activity (main) Pause, UserClosed = false **
    ** Activity (lockscreen) Create, isFirst = true **
    ** Activity (lockscreen) Resume **
    clsslidingsidebar_getviewatxy (B4A line: 469)
    If X >= v.Left And X <= v.Left + v.Width And
    java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
    at anywheresoftware.b4a.objects.ViewWrapper.getLeft(ViewWrapper.java:150)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._getviewatxy(clsslidingsidebar.java:1232)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._gesture_ontouch(clsslidingsidebar.java:859)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.agraham.reflection.Reflection$7.onTouch(Reflection.java:1118)
    at android.view.View.dispatchTouchEvent(View.java:5559)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2052)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1813)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1931)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1390)
    at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1879)
    at android.view.View.dispatchPointerEvent(View.java:5766)
    at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
    at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:859)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4441)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
    at dalvik.system.NativeStart.main(Native Method)
    clsslidingsidebar_getviewatxy (B4A line: 469)
    If X >= v.Left And X <= v.Left + v.Width And

    java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
    at anywheresoftware.b4a.objects.ViewWrapper.getLeft(ViewWrapper.java:150)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._getviewatxy(clsslidingsidebar.java:1232)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._gesture_ontouch(clsslidingsidebar.java:859)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.agraham.reflection.Reflection$7.onTouch(Reflection.java:1118)
    at android.view.View.dispatchTouchEvent(View.java:5559)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2052)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1813)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1931)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1390)
    at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1879)
    at android.view.View.dispatchPointerEvent(View.java:5766)
    at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2466)
    at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
    at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:198)
    at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:157)
    at anywheresoftware.b4a.debug.Debug.wait(Debug.java:213)
    at anywheresoftware.b4a.debug.Debug.reachBP(Debug.java:260)
    at anywheresoftware.b4a.debug.Debug.ErrorCaught(Debug.java:145)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._getviewatxy(clsslidingsidebar.java:1248)
    at com.datasteam.b4a.system.lockscreen.sample.clsslidingsidebar._gesture_ontouch(clsslidingsidebar.java:859)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:511)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:187)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:171)
    at anywheresoftware.b4a.agraham.reflection.Reflection$7.onTouch(Reflection.java:1118)
    at android.view.View.dispatchTouchEvent(View.java:5559)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2052)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1813)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2058)
    at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1785)
    at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1931)
    at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.
    Message longer than Log limit (4000). Message was truncated.
    java.lang.ClassCastException: android.widget.AbsListView$LayoutParams cannot be cast to anywheresoftware.b4a.BALayout$LayoutParams
    raiseEvent for gesture_ontouch returned null
     
    Last edited: Jul 22, 2015
  19. RandomCoder

    RandomCoder Well-Known Member Licensed User

    I'm sorry but I've not got my PC to hand at the moment so can't check the code you have already uploaded. Please show the code on line 469 where the error occurs. It's it possible that you are trying to access a property of the ListView that doesn't exist and so throwing the ClassCast error?
     
  20. khosrwb

    khosrwb Active Member Licensed User

    error occured in this sub :

    Code:
    Private Sub GetViewAtXY(X As Float, Y As Float) As Object
        
    For Each v As View In pnlContent.GetAllViewsRecursive
            
    If X >= v.Left And X <= v.Left + v.Width And Y >= v.Top And Y <= v.Top + v.Height Then       'this line is 469
                Return v
            
    End If   
          
    Next
        
    Return Null
    End Sub
     
Loading...