I’ve gone deep enough into reading the Android
documentation and in particular into saving View
states. And the sources could not answer some of the questions.
- Why do
View
s that work with text save this very text without having anid
? The documentation clearly states that there should be anid
, and this is logical, because when we receive data from theBundle
, we need to explicitly understand which widget they belong to. - For some reason,
EditText
saves the text, butTextView
does not, just why? Does it depend on the type ofTextLayout
? I know it depends on thefreezesText
and the availability of theid
. ButEditText
is able to save text withoutid
. What is the reason for the different behavior between them and why the save behavior was not implemented in theTextView
, which is the parent forEditText
.
Moreover:
- Why
EditText
orButton
will not save text in the same way asTextView
, and it should not save without anid
. - I want to add that the documentation explicitly states that the
View
must have a unique id in the current view hierarchy tree. But if theEditText
andTextView
id
s match, then when the configuration is changed, the text will be restored in both widgets. This once again confirms the recovery byid
.
I want to point out that the essence of the issues is not the implementation of a more logical widget behavior. I am interested in the reasons for the presence of such widget behavior. Some logical reasoning that I can’t find and form myself.