Android Question Input dialogs with XUI Views - size

jatko

Member
Licensed User
Longtime User
I have a problem with the inputbox based on B4XInputTemplate. I need to change the size, because I need set a little longer prompt text. The size doesn't change. Why?

Sub inputBoxNN(Prompt As String, Title As String) As ResumableSub Dim input As B4XInputTemplate dialog.Title = Title input.Initialize input.lblTitle.Text = Prompt input.ConfigureForNumbers(False, False) Wait For (dialog.ShowTemplate(input, "OK", "", "CANCEL")) Complete (Result As Int) If dialog.Visible Then dialog.Resize(80%x,20%y) If Result = xui.DialogResponse_Positive Then Dim res As Int = input.Text End If Return res End Sub:
Sub inputBoxNN(Prompt As String, Title As String) As ResumableSub
    Dim input As B4XInputTemplate
    dialog.Title = Title
    input.Initialize
    input.lblTitle.Text = Prompt
    input.ConfigureForNumbers(False, False)
   
    Wait For (dialog.ShowTemplate(input, "OK", "", "CANCEL")) Complete (Result As Int)
    If dialog.Visible Then dialog.Resize(80%x,20%y)
    If Result = xui.DialogResponse_Positive Then
        Dim res As Int = input.Text
    End If
    Return res
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
Wait For (dialog.ShowTemplate(input, "OK", "", "CANCEL")) Complete (Result As Int) If dialog.Visible Then dialog.Resize(80%x,20%y)
i may be wrong but isn´t the resize called AFTER the dialog WAS shown?

I mean: you are resizing it after the dialog is finished/closed...

Maybe
B4X:
Dim rs As ResumableSub = dialog.ShowTemplate(input, "OK", "", "CANCEL")
If dialog.Visible Then dialog.Resize(80%x,20%y) 
Wait For (rs) Complete (Result As Int)
? Never used Inputtemplates....
 
Last edited:
Upvote 0

jatko

Member
Licensed User
Longtime User
I put it befor "Wait" and it didn't change anything

When I put it without "if" before "Wait" I have an error: java.lang.RuntimeException: Object should first be initialized (B4XView).
 
Upvote 0

PaulMeuris

Active Member
Licensed User
You could of course use a custom dialog and you would be in control of the layout that you make in the designer.
Some code:
custom dialog with adjustable label height:
    Dim pnl As B4XView = xui.CreatePanel("")
    pnl.SetLayoutAnimated(0dip, 0dip, 0dip, 340dip, 200dip)
    pnl.LoadLayout("input_dialog_layout")
    Dim rsub1 As ResumableSub =  inputdialog.ShowCustom(pnl, "OK", "", "CANCEL")
    lbltitle.Text = Title
    Label1.Text = Prompt
    Label1.Height = strutils.MeasureMultilineTextHeight(Label1,Label1.Text)
    EditText1.SetLayout(10dip,50dip+Label1.Height,300dip,50dip)
    Wait For (rsub1) Complete (Result As Int)
    If Result = xui.dialogResponse_Positive Then
        ' return value
    End If
customdialog1.PNG

And this is the result:
customdialog2.PNG
 
Upvote 0
Top