Android Question PlacesAutocompleteView not working in panels

Discussion in 'Android Questions' started by Mike1970, May 22, 2019.

  1. Mike1970

    Mike1970 Active Member Licensed User

    I tried to run the example of the PlaceAutocompleteView class from Erel (https://www.b4x.com/android/forum/t...google-place-autocomplete-view.81976/#content), but if i load the layout in a panel it crashes without giving any Log message....

    Debugging i discovered that crashes on:

    Code:
    If New.Length = 0 Then
            lv.Clear
            lv.Visible = 
    False
    (This code is in the class, in et_TextChanged)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    There must be an error in the logs. In some cases the debug app crashes before it completes sending the logs. In that case the error should appear when you run the app again.
     
  3. Mike1970

    Mike1970 Active Member Licensed User

    OK, i noticed that the Debugger is not working anymore at all actually
     
  4. Mike1970

    Mike1970 Active Member Licensed User

    Ok now i see the logs xD

    I describe to you the scene..
    I have Two modules, with a button i go from the Main module to the Home module (calling StartActivity(Home)), then in Home i have few buttons that each one loads a layout in a panel (pnlContent).

    when i click the button to load the layout with the AutocompleteView it crashes and give me this error:

    Error occurred on line: 109 (PlacesAutocompleteView)
    java.lang.RuntimeException: Object should first be initialized (ListView).

    But i saw that in the "initialize" event of the class there is the function:

    lv.initiliazie("lv")

    So.. i don't understand
     
  5. DonManfred

    DonManfred Expert Licensed User

    It would help if you upload a small project which shows the issue instead of giving five answers...
     
    Mike1970 likes this.
  6. Mike1970

    Mike1970 Active Member Licensed User

    Ok, i understood how to replicate the error, here you are the small project.
    let me know if you spot something
     

    Attached Files:

  7. Willian Padilha

    Willian Padilha New Member Licensed User

    Hi this is my first interaction with the forum , in Class Module (PlacesAutoCompleteView) uncomment line 21 in Sub Initialize and comment line 36, or move line 36 before this line, example below

    Code:
    et.InputType = Bit.Or(et.INPUT_TYPE_TEXT, 0x00080000)
    Now
    Code:
    et.InputType = Bit.Or(et.INPUT_TYPE_TEXT, 0x00080000)
    lv.Initialize(
    "lv")
    expected

    Code:
    lv.Initialize("lv")
    et.InputType = 
    Bit.Or(et.INPUT_TYPE_TEXT, 0x00080000)
    It seems that when you apply InputType to an EditText, the Change method of it is activated
     
    Mike1970 likes this.
  8. Mike1970

    Mike1970 Active Member Licensed User


    I tried and it crashes again.
    Try to unistall the application and install again with "initialize" line above the et.inputtype, and you will see that it crashes again.

    Because i noticed that if you modify it, save, and restart the code it will run perfectly (without repacking from scartch), but if you stop, delete the app (restart adb server) and Reinstall WITHOUT change anything in the code, it crashes again D:
     
  9. Willian Padilha

    Willian Padilha New Member Licensed User

    Try call in first line of Initialize
    Code:
    Public Sub Initialize (vCallback As Object, vEventName As String)
        lv.Initialize(
    "lv")
        mEventName = vEventName
        mCallback = vCallback
        et.Initialize(
    "et")
        
        
    Dim cd As ColorDrawable
        cd.Initialize2(
    Colors.ARGB(180,255,255,255),5dip,2dip,Colors.RGB(233,233,233))
        
        et.Background = cd
        et.Hint = 
    "Cerca il luogo di stage"
        et.HintColor = 
    Colors.Gray
        et.SingleLine = 
    True
        
        
    'Remove the suggestions bar
        'lv.Initialize("lv")
        et.InputType = Bit.Or(et.INPUT_TYPE_TEXT, 0x00080000)
    .......................
    .............
    ...
    and comment other Initialize of lv Object
     
  10. Mike1970

    Mike1970 Active Member Licensed User


    It was one of the first things i tried... but i don't know why after some restart-run it gave problem again.

    Now i uncomment the line at the begininng of the Initialize Sub, and it's not crashing (at the moment) and it's giving this error:

    Unexpected event (missing RaiseSynchronousEvents): et_textchanged
    Check the unfiltered logs for the full stack trace.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You can ignore it.
     
    Mike1970 likes this.
  12. Mike1970

    Mike1970 Active Member Licensed User

    OK thanks all

    If the problem comes back again, i will let you know
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice