Android Tutorial Dialogs library 2017 - Custom dialogs and async methods

Status
Not open for further replies.

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tested it with this code and it works properly:
B4X:
Sub Activity_Click
   Dim dd As CustomLayoutDialog
   Dim sf As Object = dd.ShowAsync("Filtri Anagrafiche", "OK", "Annulla", "", Null, False)
   dd.SetSize(100%x, 100%y)
   Wait For (sf) Dialog_Ready(pnl As Panel)
  Dim sv As ScrollView
   sv.Initialize(1000dip)
   'pnl.LoadLayout("frmFiltriAnagrafiche")
   pnl.AddView(sv, 0dip,0dip, pnl.Width, pnl.Height)
   sv.Panel.LoadLayout("2")
   Wait For (sf) Dialog_Result(res As Int)
End Sub
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
I solved.
If it serves someone, I have changed the height of the scrollview and the form becomes dynamic and allows to overcome the vertical dimension.

B4X:
msvFiltri.Panel.Height    =    m_pnlFiltri.Height + 100dip
 

Roberto P.

Well-Known Member
Licensed User
Longtime User
It would be interesting to be able to change the background colors and dialog text, and also the style of the character.
 

vecino

Well-Known Member
Licensed User
Longtime User
Hello, and sorry for my ignorance. Maybe I'm talking nonsense.
But, is not this too convoluted?
Is there no other way to ask the user for a data?
I'm thinking something similar to this:
B4X:
Res = InputDialogAsync ("name", "", "ok", "cancel", icon)
Wait For ...
 

ema01

Member
Licensed User
Longtime User
Hi erel,
in the iOS version of an application i used iCustomDialog to create..well, custom dialogs.
I can change the background with ease, set the buttons styles with ease and so on.

Is it possible to do the same in android, without resorting to changing the theme?

basically, this is want i'd like to obtain
 

ema01

Member
Licensed User
Longtime User
To refine my question, I was able to change almost everything..

to get a uniform tint in the dialog you have to change the panel's color, obviously ("panel" is the one declared in Dialog_Ready method)
you have also to change the background of the area behind the buttons. to do so you can access that area as a view

B4X:
Dim btn As Button
btn = dialog.GetButton(DialogResponse.CANCEL)
If btn.IsInitialized Then
  Dim pnlButtons As B4XView = btn.parent
End If

pnlButtons is the view behind the dialog buttons. Now you can change the color as well.
The dialog buttons appereances can be changed of course by getting them with the BetButton method

However, there are two things i still haven't figured out how to do:
- how to change the height of the buttons and of pnlButtons
- how to get to the root of the dialog view so i can
a)change the borders, make rounded borders (applying a background to panel or pnlButtons will result in a partial rounded background, not the whole dialog)
b)make the dialog, for example, semi-transparent. could be interesting for something else i have in mind which i could do with dialogs instead of popup panels, which i'll definetly do with iCustomDialog with iOS

if anybody can help me

EDIT:
Ok, i don't know why it didn't show before, but i can actually change the buttons width and height.
I think the view behind (pnlButtons) is actually a scroll view (edit: No, it isn't), as scrolling is enabled if the height of the cancel button is smaller than the height of the other buttons. It seems it uses the cancel button's height to set its height.

I still can't access the panel behind..

EDIT2:
Almost... There...


I still can't figure out how to change the dialog view borders, nor how to change the pnlButtons height, so that i can have the same distance from bottom as it is from the sides.

I tried casting pnlButtons as a scrollView but i get this error
B4X:
java.lang.ClassCastException: com.android.internal.widget.ButtonBarLayout cannot be cast to android.widget.ScrollView

ButtonBarLayout?

Anyway, i kept referencing to parents over parents, i tried going back 5 levels hoping to find the main view or at least a null reference exception but nothing. (tested by changing the colors to different colors and then backwards to transparent.)
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…