XtraViews

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
@Thraka: Cancel Dismiss concept implemented in 1.21

Check Sample3

B4X:
Sub Dialog1_Dismiss (DialogResult As Int) As Boolean
    Dim AllowDismiss As Boolean = DialogResult = DialogResponse.POSITIVE
   
    If Not(AllowDismiss) Then
        ToastMessageShow("button is blocked!", True)
    End If 
    Return AllowDismiss
End Sub

Sub Dialog2_Dismiss (DialogResult As Int) As Boolean
    Dim AllowDismiss As Boolean = DialogResult = 2
   
    If Not(AllowDismiss) Then
        ToastMessageShow("button is blocked!", True)
    End If 
    Return AllowDismiss
End Sub
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
This is why I love B4A ... even if you can do all other high level languages, you can still do everything in B4A! And is much more fun guaranteed!

It is MAGIC!

magical-sand.gif
 
Last edited:

JakeBullet70

Well-Known Member
Licensed User
Longtime User
This is why I love B4A ... even if you can do all other high level languages, you can still do everything in B4A! And is much more fun guaranteed!

It is MAGIC!

I agree, B4A has brought back the RAD concept. .NET and JAVA have lost it.
 

ivan.tellez

Active Member
Licensed User
Longtime User
This is really awesome, great job.

If your goal is to "encapsulate as much code as possible", this is a great and flexible base to make ALL kind of dialogs. but in most apps you will be using some "Common Dialogs", but, The Native pickers are not alway a good choice.

So, I think it would be better if you add some of the most common used pickers; Date, Time, Date with Caledar and Number. A plus culd be some more advanced like, Browse for folder, Open File, Save File and Color Picker.

A little inspiration:

android-betterpickers

Thaks for the great work
 

MaFu

Well-Known Member
Licensed User
Longtime User
Great lib, thank you for this.
One question: i like to have a dialog with one listview and one cancel button. If i click on the listview the dialog should disappear with the clicked item index as response code. Is it doable?
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Thanks Mafu!

About the listview question. Sure you can.

Declare a global DialogView object and generate the Listview declaration from the layout that contains your dialog design.
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Dim Dialog As DialogView
    Public ListView1 As ListView
End Sub

Create a "show" event for your dialog using the name of the layout (in my sample "dialog") and initialize the list view
B4X:
Sub Dialog_Show
    ListView1.SingleLineLayout.Label.TextColor = Colors.Black
    For i=1 To 10
        ListView1.AddSingleLine("item #" & i)
    Next
End Sub

In the listview click handler, dismiss the global dialog passing as dialogresult the position of the clicked listview item
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
    Dialog.Dismiss(Position)      
End Sub

Show your dialog
B4X:
Sub Button1_Click
    Dim Result As Int = Dialog.LoadLayout("Dialog").Show("Please select", "", "", "cancel", Null)  
    Msgbox("Result = " & Result, "")
End Sub

Attached is a sample project :)

About your last issue. The dialog width and height are fixed and the dialog is not resizable since its width and height is defined by the width and height of the panel in your dialog layout. Can you please show some code that demonstrates the issue?
 

Attachments

  • mafu.zip
    9 KB · Views: 193

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Oh got it! you mean that the contents of the dialog are not totally visible because the height is smaller, right?

If so, I ll fix this in the upcoming version :)
 

MaFu

Well-Known Member
Licensed User
Longtime User
Thank you Periklis
Dialog.Dismiss() was the missing part.

For the resize problem: i only tested your samples in emulator, the problem is with Dialog #1 in sample2. Show the dialog and then rotate the emulator/device. "dismiss button #1" and listview are partly and label and "beep and toast button #3" are complete out of bounds.
 

MaFu

Well-Known Member
Licensed User
Longtime User
Oh got it! you mean that the contents of the dialog are not totally visible because the height is smaller, right?

If so, I ll fix this in the upcoming version :)
That's what i mean.
 

MaFu

Well-Known Member
Licensed User
Longtime User
But if i use a listview in the dialog this may have a strange misbehaviour with the underlying scrollview.
And it's no good design if i must scroll to see if there is a button to click. It depends on the views i use on the dialog.

My wish:
A new event (e.g. Dialog_Layout) that would be called on dialog start (after before Dialog_Show event) and device rotation with dialog client size as parameter. Therefore i can position (or resize) my views as needed.
 

MaFu

Well-Known Member
Licensed User
Longtime User
The problem is that once the layout is loaded, it can not be modified anymore.
Why not?
I have tested it.
In sample2 i added on Btn3_Click event (the button with the beep) the following line:
"ListView1.Width = 30%x"
It works as expected.
So if i have an event on start and rotate i can change my views.
 
Top