Android Question Multiple instances of one panel

vfafou

Well-Known Member
Licensed User
Longtime User
Hello!
I need help for the following problem:
I need to show messages from a server to a custom screen consisting of one panel with two buttons and an edittext.
My problem is:
When I have 2 messages and I press the close button to the last shown message, it closes the last message an then it appears the first message where I press the close button but the panel stays to the screen.
What could I do? I think I need to make a class and manage this function with the class, but I need help on how it could be!

Thank you in advance!
 

vfafou

Well-Known Member
Licensed User
Longtime User
Hello fixit30,
Nothing special the code:
B4X:
txtMsgText.Text = msgText
pnlMsg.BringToFront
pnlMsg.Visible = True
And when pressing close button:
B4X:
Sub btnCloseMsg_Click
     pnlMsg.visible = False
     pnlMsg.SendToBack
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I'm sorry, but I don't understand what you don't understand...
I dont understand that you dont undersstand that WE can NOT help without posting a example project which shows the problem.
You description is to vague to try to help in any kind.
 
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
OK, DonManfred!
I think it had been more clear if instead of:
"Sorry, but we have no chance to help you if you do not show us your code...", the statement was:
"Sorry, but we have no chance to help you if you do not show us a sample...", but that's my opinion!
I've been acted as stated!
I'm sorry for not understanding! I'm so stressed at the moment that I can't imagine what someone could ask to me...
Anyway, I post a sample!
 

Attachments

  • Sample.zip
    9.6 KB · Views: 178
Upvote 0

JordiCP

Expert
Licensed User
Longtime User
IfI understood correctly, your code will not do what you want because you load one panel, and get multiple (2) references to the same panel and its elements, but they are not multiple instances. So when you close one, you are closing the only panel.

I suggest another approach to get what you want (there can be many other approaches). I think there is no need for classes unless you want to customize each message's behavior too much): just use one panel, and keep the not-shown messages in a list. Each time you click on the "close" button, check if there are more messages to show, otherwise hide it.
 

Attachments

  • Sample.zip
    5.3 KB · Views: 176
Upvote 0

vfafou

Well-Known Member
Licensed User
Longtime User
Hi JordiCP,
Thank you for your response!
Some times I (we) do more complicated thoughts about how to solve a specific problem!
Your approach is very simple and I think it will save me a lot of time!
Thank you very much!
 
Upvote 0
Top