Android Question XUI Views (Ver 2.00) Breaks CustomListView

Discussion in 'Android Questions' started by MrKim, May 10, 2019.

  1. MrKim

    MrKim Active Member Licensed User

    I just needed an Input Dialog similar to the one in Access/VBA.
    It looks like XUI Views has what I need.
    The problem is it breaks a bunch of existing code that uses CustomListView (Which I have modified for my needs)

    Exisiting example:
    Code:
    CLV1.Add(CreateListItem("Done", CLV1.AsView.Width, 50dipColors.DarkGray, Colors.White, 16), 50dip"TextColorsDone")
    Evidently XUI Views also contains/steps on something called CustomListView?

    What is breaking is the .Add - Mine has an extra parameter for the height of the added panel.
    I also notice that the XUI version requires a B4XView, not a panel. How much recoding is involved there?

    OLD:
    upload_2019-5-9_23-59-50.png

    VS NEW:

    upload_2019-5-9_23-59-0.png

    Don't mind fixing the code if I can get the same results and it is the future. And it doesn't take too long.

    On the other hand keep in mind all I am after here is a 'Modal' Dialog to enter some text. I am just trying to get a job done.

    Thanks for your help.
     

    Attached Files:

  2. Erel

    Erel Administrator Staff Member Licensed User

    The problem is that you are using a modified version of xCustomListView. What have you modified? Maybe it is not needed.

    If you must use a modified version then you have two options:
    1. Rename the modified module. You will also need to rename the custom types and update the code. It will require some work.
    2. Build a library from the modified code and replace the internal xCustomListView library with your own.

    Best option is to use the stock library. You can probably use it and change the behavior from outside the class.
     
  3. MrKim

    MrKim Active Member Licensed User

    Thanks for your help Erel.

    The xCustomListView library is not loaded. I am using a Class Module Called CustomListView that I got here somewhere.
    Here is the list of Libs in my app:
    upload_2019-5-10_0-49-26.png

    Here is the beginning code from the Class Module:
    Code:
    'version: 1.10
    #Event: ItemClick (Index As Int, Value As Object)
    Sub Class_Globals
        
    Public sv As ScrollView
        
    Private items As List
        
    Private panels As List
        
    Private dividerHeight As Float
        
    Private pressedDrawable As Object
        
    Private EventName As String
        
    Private CallBack As Object
        
    Private su As StringUtils
        
    Public DefaultTextSize As Int
        
    Public DefaultTextColor As Int
        
    Public DefaultTextBackgroundColor As Int
        
    Private DefaultTextBackground As Object
    End Sub

    Public Sub Initialize (vCallback As Object, vEventName As String)
        sv.Initialize2(
    0"sv")
        items.Initialize
        panels.Initialize
        dividerHeight = 
    2dip
        EventName = vEventName
        CallBack = vCallback
        sv.Color = 
    0x597E89 'this sets the dividers color
        Dim r As Reflector
        
    Dim idPressed As Int
        idPressed = r.GetStaticField(
    "android.R$drawable""list_selector_background")
        r.Target = r.GetContext
        r.Target = r.RunMethod(
    "getResources")
        pressedDrawable = r.RunMethod2(
    "getDrawable", idPressed, "java.lang.int")
        DefaultTextColor = 
    Colors.White
        DefaultTextSize = 
    16
        DefaultTextBackgroundColor = 
    Colors.Black
        DefaultTextBackground = 
    Null
    End Sub

    'Returns a view object that holds the list.
    Public Sub AsView As View
        
    Return sv
    End Sub
     
  4. kisoft

    kisoft Active Member Licensed User

    A better solution is to use the xcustomlistview library instead of the class module. Delete the old customlistview element from the layout and create a new one.
     
  5. klaus

    klaus Expert Licensed User

    Be aware that the XUI Views B4XLibary depends on xCustomListView!
     
  6. MrKim

    MrKim Active Member Licensed User

    I am able to run the example program and it does not have the xCustomListView lib loaded.
     
  7. MrKim

    MrKim Active Member Licensed User

    FYI, I solved the problem by Renaming my Class Module CustomListView to KimsCustomListView. Once I did that it showed up as a new custom view so I added it to my activity in designer, copied all of the properties from the old CustomListView to the new KimsCustomListView, then deleted CustomListView and renamed KimsCustomListView CLV1.
    Everything works and I have my Input Dialog. I am a happy man!

    Yes, at some point I would like to switch everything over to the newer stuff but sometimes we just need to get a job done.
    This is one of those times.
    I'm guessing that if I had been using xcustomlistview library instead of the class the fix would not have been so simple.
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    There would nothing to fix in that case. It would just work.
     
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