Android Question Click Event not fire inside dialog

chaiwatt

Member
Licensed User
Longtime User
Hi Erel, I really need help. My simple project contain one button and listview inside dialog. once I try to fire event click of both control but there are seem no trigger. Appreciated for advise, here is my code and sorry for my English.

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private btnStart As Button
Private lstTest As ListView
Private btnTest As Button
Private pnl As Panel
Private mtabhost As TabHost
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
mtabhost.Initialize("")
pnl.Initialize("")
pnl.AddView(mtabhost,0%x, 0%x, 100%x, 100%y)
mtabhost.AddTab("Tab1", "page1")
mtabhost.AddTab("Tab2", "page2")
lstTest.AddSingleLine ("some text")
End Sub

Sub lstTest_ItemClick (Position As Int, Value As Object)
Msgbox ("Test click on listview","")
End Sub

Sub btnTest_Click
Msgbox ("Test","")
End Sub

Sub btnStart_Click
Dim dlg As CustomDialog2
dlg.AddView(pnl,100%x, 50%y)
dlg.Show("Manager", "OK", "", "", Null)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
 

Attachments

  • tabhost.zip
    387.1 KB · Views: 233
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Don't limit your questions to a single member.
2. Use code tags when posting code.
3. Use File - Export as zip when uploading projects.
4. Don't bump your questions. Especially not after 46 minutes.

You cannot handle events in a modal dialog. Use a non-modal dialog (a regular panel).
 
Upvote 0

chaiwatt

Member
Licensed User
Longtime User
1. Don't limit your questions to a single member.
2. Use code tags when posting code.
3. Use File - Export as zip when uploading projects.
4. Don't bump your questions. Especially not after 46 minutes.

You cannot handle events in a modal dialog. Use a non-modal dialog (a regular panel).
Dear Erel, thanks.
 
Upvote 0

Steve Kwok

Member
Licensed User
It work by replacing CustomDialog2 by CustomLayoutDialog!

B4X:
Sub btnStart_Click
    'Dim dlg As CustomDialog2   
    'dlg.AddView(pnl,100%x, 50%y)   
    'dlg.Show("Manager", "OK", "", "", Null)   
    
    Dim dialog As CustomLayoutDialog
    Dim sf As Object = dialog.ShowAsync("Manager", "OK", "", "", Null, False)
    Wait For (sf) Dialog_Ready (DialogPanel As Panel)
    DialogPanel.AddView(pnl,0dip, 75dip, 100%x, 50%y)   
    Wait For (sf) Dialog_Result (Result As Int)
    If Result = DialogResponse.POSITIVE Then
        '...Do Something
    End If   
End Sub
 

Attachments

  • Screenshot_2018-05-09-18-54-10.png
    Screenshot_2018-05-09-18-54-10.png
    41.6 KB · Views: 226
  • Screenshot_2018-05-09-18-54-20.png
    Screenshot_2018-05-09-18-54-20.png
    43.1 KB · Views: 203
Upvote 0
Top