Android Question Chat like layout : problem with Autoheight for listview

Discussion in 'Android Questions' started by Reids, Jun 24, 2015.

  1. Reids

    Reids Member Licensed User

    Hello, I have read, and do experiment with all listview on this forum, custom listview, mylistview, flexibellistview, but I still cannot find "how" to autoheight the label, or text inside listview but with image beside it.
    On customlistview we have procedure to autoheight the text with .AddTextItem() but there is no example which customlistview can autofit the text height with image on side it (like bbm or whatsapp chat layout)
    I also tried to use stringutils which calculating the required needed height based on label, but it also doesn't work
    Finally, I only could create this chat layout but I cannot find how to autoheight the text

    The code is
    #Region Module Attributes
    #FullScreen: False
    #IncludeTitle: True
    #ApplicationLabel: ListView example
    #VersionCode: 1
    #End Region

    Sub Process_Globals

    End Sub

    Sub Globals
    Dim ListView1 As ListView
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
    Dim GD As GradientDrawable
    "TR_BL"Array As Int(Colors.Gray, Colors.LightGray))
    Activity.Background = GD
        ListView1.ScrollingBackgroundColor = 
    Dim Bitmap1 As Bitmap
    File.DirAssets, "button.gif")
        ListView1.FastScrollEnabled = 
    For i = 1 To 500
    ListView1.TwoLinesAndBitmap.SecondLabel.Color = 
    ListView1.TwoLinesAndBitmap.SecondLabel.Width =

    ListView1.TwoLinesAndBitmap.ImageView.Left = 
    100%x - 50dip
    ListView1.TwoLinesAndBitmap.Label.Left = 
    ListView1.TwoLinesAndBitmap.Label.Width = 
    100%x - 50dip
    ListView1.TwoLinesAndBitmap.SecondLabel.Left = 
    ListView1.TwoLinesAndBitmap.SecondLabel.Width = 
    100%x - 50dip

    ListView1.TwoLinesAndBitmap.SecondLabel.Height = 
    100%y - 50dip
    100%y - 50dip

    "Title 2""this is looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong text and need to autoheight"LoadBitmap(File.DirAssets, "button.gif"))
    Activity.AddView(ListView1, 00,Activity.Width, Activity.Height)
    End Sub
    Sub ListView1_ItemClick (Position As Int, Value As Object)
    Activity.Title = Value
    End Sub
    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Please help me
    Thank you
  2. MarcoRome

    MarcoRome Expert Licensed User

    Look this:

  3. Reids

    Reids Member Licensed User

    Sorry I prefer the "free" solution :(
  4. Erel

    Erel Administrator Staff Member Licensed User

    See how CustomListView.AddTextItem is implemented. You can do something similar and add an image.
    Reids likes this.
  5. Reids

    Reids Member Licensed User

    Thank you @Erel finally I found the instant way here , found it by accident by follow your clue and manage to add other object with relative height size, when searching again I found the instant way lol

    Thank You verymuch!
  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