Android Question Restore View after removing

Startup

Active Member
Licensed User
Longtime User
I want to restore a view after removing it. I have 2 buttons created in designer. I remove one button but can't then restore it using addView. Here's my code --
Sub btnRemove_Click
Activity.RemoveViewAt(0)
End Sub
Sub btnActivate_Click
Dim btnActivate As Button
Activity.AddView(btnActivate,200dip,100dip,100dip,100dip)
End Sub
How do I restore a View I've removed?
 

udg

Expert
Licensed User
Longtime User
I agree with Klaus about the Visible property.

Anyway, your code doesn't look correct to me.
Assuming that in Designer you have two buttons named "btnActivate" and "btnRemove", in that order, when you firstly click the one for removal you eliminate the other button. And a second click would eliminate the removal button too..
Well, but if you just removed btnActivate (due to btnRemove_Click) how can you call its click function?
And more, in btnActivate_Click you redim that same btnActivate, a button originally initialized in the Designer.

udg
 
Upvote 0

Startup

Active Member
Licensed User
Longtime User
I agree with Klaus about the Visible property.

Anyway, your code doesn't look correct to me.
Assuming that in Designer you have two buttons named "btnActivate" and "btnRemove", in that order, when you firstly click the one for removal you eliminate the other button. And a second click would eliminate the removal button too..
Well, but if you just removed btnActivate (due to btnRemove_Click) how can you call its click function?
And more, in btnActivate_Click you redim that same btnActivate, a button originally initialized in the Designer.

udg
Yes code was incorrect. Here is corrected (commented) and changed to visible, invisible (uncommented) which is much better! Thanks!

Sub btnRemove_Click
'Activity.RemoveViewAt(0)
btnRemove.Visible = False
End Sub
Sub btnActivate_Click
'Activity.AddView(btnRemove,50dip,100dip,100dip,100dip)
btnRemove.Visible=True
End Sub
 
Upvote 0
Top