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
What layout should i use
they do not have any layout.

B4X:
Dim n As Notification
n.Initialize
n.Icon = "icon"
n.SetInfo("This is the title", "and this is the body.", Main) 'Change Main to "" if this code is in the main module.
n.Notify(1)

More powerful is the notificationbuilder class

 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
NO!

A Notification does not include any other layouts.

You can use an Icon, a text to show and maybe some settings to show a longer text.

there is a possibility to extend a notification with some actionbuttons. But the layout is given by Android.

I can not help on this though. Never needed Notifications with actionbuttons.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
No, never build such a layout. You need to do it by yourself

The relevant thread is here:
 
Upvote 0

ProjectGroup19

Active Member
Licensed User
No, never build such a layout. You need to do it by yourself

The relevant thread is here:
Alright. Thank you.
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
It seems the items are expandable, you could use this, based in xCustomListView too

 
Upvote 0

ProjectGroup19

Active Member
Licensed User
It seems the items are expandable, you could use this, based in xCustomListView too

Thank you
 
Upvote 0

Albert Kallal

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:

OneRow.png


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:
PIckPaste.png


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
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
So, the result should look something like this
This is for the layout itself. Correct.

But the question in #13 was about the Dateformat used.

@ProjectGroup19 you need to set the correct DateFormat to get the wanted result


15th is language specific i guess. In germany there is no such thing. it is always "[dayinmonth]." (1. Jan, 2. Jan, 15. Jan)

I guess this is near your wish

B4X:
    Dim today As Long = DateTime.Now
    DateTime.DateFormat = "EEE d MMM yyyy"
    Log($"${DateTime.Date(today)}"$)

Sa. 11 Jan. 2020
 
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
thank you soo much Albert. I'm truly grateful for your help.
 
Upvote 0

Albert Kallal

Active Member
Licensed User
Thanks for jumping in - I am still rather new to B4A - but helping out folks is a real great way to learn.
I cobbled together this code for the user:
B4X:
Dim myDt As Long = DateTime.Now
 
Label3.Text       = DateUtils.GetDayOfWeekName(myDt) & ", " & DateUtils.GetMonthName(myDt) & " " & DateTime.GetDayOfMonth(myDt)

So the above (certainly a bit messy) will result in the date format as text as noted.

I think the user wanted full week day text, and same for month text.

So this for the new user will give the whole text for month, and whole text for the day of week.
B4X:
DateTime.DateFormat = "EEEE d MMMM yyyy"

However, how is DateTime.DateFormat localized to the one bit of code?

If this is a global change, then I assume that one "really" better always set the desired format before use then? (or set it back after use?).

Is there a way to scope that dateformat to the one routine? (say create a instance of DateTime?).

As a general rule, I don't like global scoped changes for things like a simple date display, but if that's the B4A way, then I keep this in mind.


Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0

Albert Kallal

Active Member
Licensed User
thank you soo much Albert. I'm truly grateful for your help.

You are most welcome. I am relative new here too. The challenge here is what UI choice is a good one? There is overlap in many of the choices. So, what to use? So do I use a listview, tableview, a scollview, or even some panel that expands? Which UI does one choose - that's a real trick! It hard to know the optional choice! (but, I do love how xCustomListView allows one to lay out one row with the designer - so far this is my #1 favorite feature I found in B4A).

I am not used to having to dig so much for a how to do things. However it is great on my part - this means I am not the "know it all" in the room!!

The example layout took me very little time. I actually spent more time searching after I dropped the imageview on the designer, and THEN how come the designer does not show a list of images that I included in the project for a choice? That little side trip took me longer then the whole post and building the example!!!

So I learned that after adding files to the project (main IDE - windows->Files manager). You THEN have to add the files "again" while in the layout designer. And THEN you can use the combo box to select the image for the imageview control. So some extra steps and a few jumps was required to select the image for above! I will not forget how that works after that side track show!!!!

So, I share the "fog" of learning here! - but then again - its still fun to learn new things - and thankfully B4A has a great forum, great people, and I am growing fond of the whole system and approach that B4A uses.

Regards,
Albert D. Kallal
Edmonton, Alberta Canada
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
So I learned that after adding files to the project (main IDE - windows->Files manager). You THEN have to add the files "again" while in the layout designer.
You can avoid the first step.
When you need files in the Designer, add those directly in Designer Files Tab.
They will automatically added in the IDE Files Manager Tab.
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
[OT]
To @ProjectGroup19 and all the other New Members I would like to point out just a small note.
Many Expert Users could give the "Ready Code Solution" to nearly every question in minutes.
Often this does not happen, instead the answers are links to other threads that contains the informations needed to solve the problem but yet not the finished code.
It's then expected that the new member post some code to show that he is trying to move some steps to the solution.
That's has 2 major advantages:
- the New Member start to study and code and things will remain impressed in his mind;
- Advanced Users see the effort and are more than happy to explain and correct the code.
Obtaining directly the code needed can put a member in the condition Not To Learn but just to Assemble.
This post is absolutely not a Criticism but a Hint or Guideline to Understand Coding.
[/OT]
 
Upvote 0
Top