Can somebody tell me how to hide views for always?
I'm hiding a view with view.setVisibility(view.GONE);
but when reopen the app I have to re-hide the view. I want a view hide for always when button is clicked until clearing app data or uninstalling. Thanks!
Your current approach is the programmatic one and is probably what you will have to use if you want a button to toggle the visibility of a view. The only other option of which I am aware would be to disable visibility from the XML layout file:
There is not option to permanent hide but you can achieve by this way
1.Remove the specific
view
byyou have to save the state to
show/hide
theview
on permanent storage likeShare preference / databases
Shared Preference Example
1.store value in
sharedPrefernces
:2.get value from
sharedPreferences
:You have to use
SharedPreferences
, when you hide theView
then store a value inSharedPreferences
, and when you come back to the app get value fromSharedPreferences
and according to that value hide yourView
by the same method that you are using.Getting value from SharedPreferences
reference from SharedPreferences example
You need to save state by creating flag for hide and unhide view in
SharedPreference
and basis of that flag you need to GONE or VISIBLE View.