Android Question How to create a Layout like this

ProjectGroup19

Active Member
Licensed User
Screenshot_20200104-173656_1578412960712.jpg


Please how do i do something like this?
Contents loaded from my database
 

DonManfred

Expert
Licensed User
Longtime User
[OT]
to nearly every question in minutes.
But it needs this minutes (note that it implies a multiple of a Minute) to write one. Giving the Url for the relevant Tutorial is usually done in less than a minute.
For some Tutorials i do have shortcuts to copy the url easily; A answer can be done in less then 10 Seconds.

The threadopener does not really learn how it works when he just need to copy some code. The learneffect is zero.

It is not my intention to do the work for anyone if one can do it by himself if he knows how it works.
[/OT]
 
Upvote 0

ProjectGroup19

Active Member
Licensed User
Ok, we assume you are using xCustomList view. This is a nice approach since you can layout one row something like this:

View attachment 87381

And as per say xCustomListView example, then your code to load up one row will look like:
B4X:
Sub LoadOneRow(i As Int) As B4XView

    Dim p As     B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0 ,0,0,100%x,  180dip)
  
    p.LoadLayout("OneRow")

    Label1.Text       = Label1.Text & " " & i
    Label2.Text       = "Hello xxxxxxxxxxxxxxxxxxx" & CRLF & "Next line of some annoucement text"

    Dim myDt As Long = DateTime.Now
  
    Label3.Text       = DateUtils.GetDayOfWeekName(myDt) & ", " & DateUtils.GetMonthName(myDt) & " " & DateTime.GetDayOfMonth(myDt)
    p.Tag = i
    Return p

End Sub

So, in above, (use the DateUtils library - the above line for label3.text = shows the format I used.

So, the result should look something like this:
View attachment 87382

So the line for date assumes that myDt has a date. In the above, I just passing "i" in a for next loop, but in your case you would be grabbing data from the database.

So my small loop that feeds the "one row load" routine is this:

B4X:
Sub LoadMyRows
    Dim i As Int
   
    For i = 1 To 10
        Dim obj As Object
        CustomListView1.Add(LoadOneRow(i), obj)
    Next
End Sub

(in your case, you could/would pass the row of data.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
With the Label2, if the string is lengthy, some part won't be shown. How do you deal with that?
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
With the Label2, if the string is lengthy, some part won't be shown. How do you deal with that?
Add StringUtils library to your project.
Then use
Label Sizing:
dim su as StringUtils
MyLabel.height = su.MeasureMultilineTextHeight(MyLabel,MyLabel.Text)
Hope I understood your needs.
Of course use your Label name. ;) :)
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
It looks like there is a Maximum Default Height (like the second post) that can hide longer messages in the Label anyway.
This is something that you must decide how to manage, and it's all a matter of playing with the resize of the Panel (that contain all the post) and the Label (that contain the main message).
You have to decide a Standard Layout, apart from the lenght of the message that it will contain.
Then, when clicking it, you should make a resize of the Panel and of the Label (maybe using the code that I suggested above) to show the entire message.
Start playing with this informations for now if you can.
Did you managed to display something up to now?
If possible show us the relevant code (where you create the panel and add it to the CLV) so we can help you with your code.
 
Upvote 0

ProjectGroup19

Active Member
Licensed User
It looks like there is a Maximum Default Height (like the second post) that can hide longer messages in the Label anyway.
This is something that you must decide how to manage, and it's all a matter of playing with the resize of the Panel (that contain all the post) and the Label (that contain the main message).
You have to decide a Standard Layout, apart from the lenght of the message that it will contain.
Then, when clicking it, you should make a resize of the Panel and of the Label (maybe using the code that I suggested above) to show the entire message.
Start playing with this informations for now if you can.
Did you managed to display something up to now?
If possible show us the relevant code (where you create the panel and add it to the CLV) so we can help you with your code.
B4X:
Sub CreateListItem( Width As Int, Height As Int) As Panel
    'Dim p As B4XView=xui.CreatePanel("")
    'p.SetLayoutAnimated(0,0,0,100%x, 180dip)
    Dim p As Panel
    p.Initialize("")
    p.SetLayout(0, 0, Width, Height)
    p.LoadLayout("ALAYOUT")
   
lblTitle.Text = Connection.cu.GetString("TITLE")
    lblDescription.Text = Connection.cu.GetString("DESCRIPTION")
    lblDescription.Height=su.MeasureMultilineTextHeight(lblDescription,lblDescription.Text )
    
Dim date As Long = Connection.cu.GetString("DATE")
    Dim time As String = Connection.cu.GetString("TIME")
   
    lblDate.Text=DateUtils.GetDayOfWeekName(date)&", "&DateUtils.GetMonthName(date)&" "&DateTime.GetDayOfMonth(date)&", "&DateTime.GetYear(date)&" "&time'.GetHour(time)&":"&DateTime.GetMinute(time)&":"&DateTime.Getsecond(time)
   
    Return p
End Sub
 
Upvote 0

ProjectGroup19

Active Member
Licensed User
It looks like there is a Maximum Default Height (like the second post) that can hide longer messages in the Label anyway.
This is something that you must decide how to manage, and it's all a matter of playing with the resize of the Panel (that contain all the post) and the Label (that contain the main message).
You have to decide a Standard Layout, apart from the lenght of the message that it will contain.
Then, when clicking it, you should make a resize of the Panel and of the Label (maybe using the code that I suggested above) to show the entire message.
Start playing with this informations for now if you can.
Did you managed to display something up to now?
If possible show us the relevant code (where you create the panel and add it to the CLV) so we can help you with your code.

clv.Add(CreateListItem( clv.AsView.Width, 180dip), i)
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
OK.
In the afternoon I will try to give you some advices.
It would be good to edit the Discussion Title to something like "How to create a Layout like this?", because the actual title is meaningless.
And you got your answer here.
Now for the new question it would be good to create a New Discussion with a title like "How to resize and adapt a CLV Item?".
This is the good and requested way to use the forum to avoid informations dispersion.
One Question for Discussion.
In the case you can start the first post of the new discussion linking this discussion telling that is a related thing.
It's a bit tricky but you will get used to.
And be sure that you will receive all the answers.
In the meantime try to search in the forum for the same topic.
You could already find partial or total answer.
 
Upvote 0
Top