I have an English teaching app where the users are given some sentences with their Turkish equivalents. I retrieve the data from Strings.xml as follows:
<.b>Possession (Aitlik)</b>\n\nhave
(sahip olmak)\npossess (sahip olmak)\nown (sahip olmak)\nbelong (ait olmak)\nconsist (-den meydana gelmek)\nlack (eksik olmak)\ninvolve
(içermek)\n\n<.b>Emotions (Duygular)</b>\n\nlike (sevmek)\ndislike (sevmemek)\nprefer (tercih etmek)\nappreciate (takdir etmek)\nneed
(ihtiyacı olmak)\nwish (istemek, dilemek)\nhope (ummak)\nvalue (değer vermek)\nadore (hayran olmak)\nfear (korkmak)\nsurprise (şaşırtmak)\nenvy
(kıskanmak)\nhate (nefret etmek)\nlove (sevmek)\n\n
...
If the user wishes, I'd like to hide the translations of the words. Is there a way to do it? So far, I tried separating the example sentences from their translations and hiding the translations from the code:
<string name=header_one>"<.b>Possession</b>"</string>
<string name=header_one_translation>"<.b>Aitlik</b>"</string>
binding.hideTranslationsButton.setOnClickListener {
binding.headerOneTranslation.isGone = true
binding.translationOne.isGone = true
binding.translationTwo.isGone = true
binding.translationThree.isGone = true
binding.translationFour.isGone = true
binding.translationFive.isGone = true
binding.translationSix.isGone = true
...
}
but it took too much time and it feels like my code has gotten messier considering I have 50 other grammar topics like this (I put dots intentionally --> <.b>).
CodePudding user response:
use recycleview and handle hide text in adapter of recycleview
CodePudding user response:
Maybe think about reordering your layouts.
Dunno what your structure is.
<LinearLayout id=root>
<LinearLayout id=english>
<LinearLayout id=sentence1/>
<LinearLayout id=sentence2/>
</LinearLayout>
<LinearLayout id=turkish>
<LinearLayout id=translate1/>
<LinearLayout id=translate2/>
</LinearLayout>
</LinearLayout>
and now you hide the turkish layout.