XtraViews

MaFu

Well-Known Member
Licensed User
Longtime User
Hi Periklis
At first, your lib is great. I think, it's the best dialog library for B4A so far.

But i found an error in the new version 1.32.
If i rotate the device, the dialog stays open. If i rotate the device back, the dialog disappears.
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
The reason is that a specific event (onOrientationChanged) is not raised correctly in the genymotion emulator. In the past, the dialogview did not catch that event in order to dismiss itself.
 

ivan.tellez

Active Member
Licensed User
Longtime User
Hi I think I found a bug.

You can design custom layouts and its a great feature, but, to have the dialog buttons, you use the tag.

The problem is that you cant use this property anymore :(


When you have many buttons, you have to write a lot of code to handle them, unles you do in a unique even.

For example, to create a dialog with 10 buttons and have only one event, I usualy do...

B4X:
Sub BtnXXX_Click

Dim b As Button
b = Sender
If b.Tag = "NX" Then
    'Some stuff
If b.Tag = "NY" Then
    'More stuff
Else
    'Extra stuff
End If
End Sub


But, You are not handdling correctly the Tags in the lib code, if a button's tags has for example "NX", raises a NumberFormatException:

java.lang.NumberFormatException: Invalid int: "NX"

Maybe yo can just Filter Integer tags to be the Responses AND let the Non Numeric tags to be used in B4A Code

OR

Let all the tags be available to B4A Code unless it has some special character indicating to be a "response button", For example:


B4X:
'This buton will raise the click event and could use the Tag with the sender Object
MyButton1.Tag = "1"

'This Button will dismiss the dialog and return 1 as the Response
MyButton1.Tag = "~1"


Please Let me know what you think.

Thanks
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Hi Ivan,

this is intentional. The library requires that the tag is numeric because the result of the dialog.ShowXXX call is numeric (int) . If it is not, an exception will be raised.
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
You should not have an onclick handler on dialog buttons that have a tag. The tag is used to identify the button to close the dialog and returns the tag as a result.
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
You should move the evaluation (BtnXXX_Click) after the Show call. Your code should be:

B4X:
Dim Result as Int = Dialog.LoadLayout("dialog1").ShowDefault("title", "message")
If Result = 1 Then 'NX
    'Some stuff
else If Result = 2 Then 'NY
    'More stuff
Else
    'Extra stuff
End If
 
Last edited:

MaFu

Well-Known Member
Licensed User
Longtime User
The reason is that a specific event (onOrientationChanged) is not raised correctly in the genymotion emulator. In the past, the dialogview did not catch that event in order to dismiss itself.
Thank you for the info.
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Ivan, I think that I now understand what you mean and you are right. I will modify the code so that if the tag is not numeric, it will be ignored and the default onclick handler will be called.
 
Last edited:

ivan.tellez

Active Member
Licensed User
Longtime User
Hi, yes, I knew that the tag was returned as the response, also knew that the respons could be evaluated afther the dialog is dismiss.

It has no problem on a simple dialog MsgBox style. The problem is when you wwhant to do something more complex.

Imagine you want to do a dialog to pick a number and it has 13 buttons (0-9, +/-, Backspace, Period). In here, you need to have onclick handler to process the user input. Maybe an HexPad, you need more buttons.

In this case, maybe you could use Button.Text instead of Button.Tag

But, Imagine that you want to make a Date Picker, and has 12 Buttons to select the Month, and your app can be localized to several languajes. Using the Text property its no longer useful, and here is when you really miss the use of a Tag.
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
You may have missed my last post:

Ivan, I think that I now understand what you mean and you are right. I will modify the code so that if the tag is not numeric, it will be ignored and the default onclick handler will be called.
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Ivan, get the latest version (I just updated it). The tag will be ignored if it is not numeric.
 
Last edited:

ivan.tellez

Active Member
Licensed User
Longtime User
Ups, Im Sorry, I missed the post.

An yes I tried the las version and it works great.

Thanks
 

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Updated: 1.33

You can now set the dimensions of a DialogView (check sample1):
B4X:
Dialog.Options.Dimensions.Set(100%x, 100%y)

'Alternative use:
'Dialog.Options.Dimensions.Width = 100%x
'Dialog.Options.Dimensions.Height = 100%y
upload_2014-7-18_13-38-49.png
upload_2014-7-18_13-39-6.png

upload_2014-7-18_14-24-29.png



Note: The % factor will not work well with the system title and buttons, only with custom title and buttons (will be fixed in the next version).

The engine will respect the design anchors and resize all controls as needed.

Kudos to @Erel for the clean back-end code and the excellent LayoutBuilder class :D
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Update: 1.34

DialogView is now almost perfect!

You can access views in your layout in 2 ways.

1. In the conventional way by generating a declaration of the view in the designer and then accessing the view in code.
2. Or in the new super cool and abstract way by using the DialogView.GetView method
B4X:
Sub Dialog1_Show
    Dim Dialog As DialogView = Sender

    Dim Label1 As Label = Dialog.GetView("label1")
    Label1.Text = "Yo!"
End Sub

Enjoy! :D
 
Last edited:

Periklis Koutsogiannis

Active Member
Licensed User
Longtime User
Another example of the flexibility of the DialogView is the following sample:

B4X:
Dim Dialog As DialogView

'Load the layout into a DialogViewLayout
Dim DialogLayout As DialogViewLayout = Dialog.LoadLayout("Dialog1")

'DialogViewLayout has also a GetView method that can be used to access layout views
'Get a reference to the Label1 object in the Dialog1 layout
Dim Label1 As Label = DialogLayout.GetView("Label1")

'Set the label text
Label1.Text = "this is a text"

'Show the custom dialog
Dim Result = DialogLayout.ShowOk("", "done")

This way, you can load the layout, initialize the contents of the dialog, and then show it without the need of the show event anymore. This is now the standard way of accessing layout views.
 
Last edited:

ivan.tellez

Active Member
Licensed User
Longtime User
This way, you can load the layout, initialize the contents of the dialog, and then show it without the need of the show event anymore. This is now the standard way of accessing layout views.

Wow, this is great. Really useful to make some tweaks to the dialog.


B4X:
Dim DialogLayout As DialogViewLayout = Dialog.LoadLayout("Dialog1")

After I had an Idea to do something like this Embedding files in compiled libraries

Could be posible to add another sub to load a layout from a InputStream to be able to do something like this:

B4X:
Dim LayoutFile As InputStream
LayoutFile = LoadLaoutFromJar("DlgLayout")
Dim DialogLayout As DialogViewLayout = Dialog.LoadLayoutFromInput(LayoutFile)

http://www.b4x.com/android/forum/threads/embedding-files-in-compiled-libraries.37689/And by the way, Its possible to use something like this to embed the animations in your library's Jar?

Thanks
 

Jaames

Active Member
Licensed User
Longtime User
I was thinking, this can be used as a navigation drawer with stdActionBar :D
because it has perfect animations, and look and feel is perfect as well :) Good Job!
 
Last edited:
Top