<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Viacheslav Antonenko on Medium]]></title>
        <description><![CDATA[Stories by Viacheslav Antonenko on Medium]]></description>
        <link>https://medium.com/@antslava?source=rss-6547b7c7d6d5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*q0__wREs6nUdc_bQ.jpg</url>
            <title>Stories by Viacheslav Antonenko on Medium</title>
            <link>https://medium.com/@antslava?source=rss-6547b7c7d6d5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 11:25:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@antslava/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[CheckedTextView does not save its state.]]></title>
            <link>https://medium.com/android-dev/checkedtextview-does-not-save-its-state-43903ab19de?source=rss-6547b7c7d6d5------2</link>
            <guid isPermaLink="false">https://medium.com/p/43903ab19de</guid>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Viacheslav Antonenko]]></dc:creator>
            <pubDate>Thu, 18 Feb 2016 18:06:10 GMT</pubDate>
            <atom:updated>2016-02-18T18:06:10.870Z</atom:updated>
            <content:encoded><![CDATA[<p>Few weeks ago I found an interesting issue after device orientation change <a href="http://developer.android.com/intl/ru/reference/android/widget/CheckedTextView.html"><em>CheckedTextView</em></a> does not save checked state.</p><p>I started to research the question “Why <em>CheckedTextView</em> does not save its state”. The first idea that comes to my mind was “Maybe I forgot to set <em>id</em>?”. Because, as we know, Android does not save <em>View</em> state if it does not have an <em>id</em>. However, it was set.</p><p>Next step was to check Android sources and after some research, I found that <a href="http://developer.android.com/intl/ru/reference/android/widget/CheckedTextView.html"><em>CheckedTextView</em></a> does not save its state.</p><p>This finding very surprised me because <a href="http://developer.android.com/intl/ru/reference/android/widget/CheckedTextView.html"><em>CheckedTextView</em></a> exists from API 1 and it means that this issue already exists for many years.</p><p>Now I know what the problem is and correct it not be difficult. Below you can find a solution to fix this issue.</p><p>Firstly we need to create an own class that extent <a href="http://developer.android.com/intl/ru/reference/android/widget/CheckedTextView.html"><em>CheckedTextView</em></a> or <a href="http://developer.android.com/intl/ru/reference/android/support/v7/widget/AppCompatCheckedTextView.html"><em>AppCompatCheckedTextView</em></a> if you use support library.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0bf358979d2d266d728e8f05acfa1ac9/href">https://medium.com/media/0bf358979d2d266d728e8f05acfa1ac9/href</a></iframe><p>The second step is to create a class that save and restore our state. This class must extend <a href="https://developer.android.com/reference/android/view/View.BaseSavedState.html"><em>BaseSavedState</em></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/293f4ce29ee064caf403f69887beecd4/href">https://medium.com/media/293f4ce29ee064caf403f69887beecd4/href</a></iframe><p>So last step was save our state at <a href="https://developer.android.com/reference/android/view/View.html#onSaveInstanceState()"><em>onSaveInstanceState</em></a> and restore it at <a href="https://developer.android.com/reference/android/view/View.html#onRestoreInstanceState(android.os.Parcelable)"><em>onRestoreInstanceState</em></a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4ba38c554af267ae0c18cae49b1d9875/href">https://medium.com/media/4ba38c554af267ae0c18cae49b1d9875/href</a></iframe><p>The complete solution you can find at my <a href="https://gist.github.com/antslava/cea2f0297ba7add6ed4d">gist</a>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6c80cbd8d80eac17313d52dc242b434/href">https://medium.com/media/e6c80cbd8d80eac17313d52dc242b434/href</a></iframe><p>Also, I created an issue at Android bug tracker.</p><p><a href="https://code.google.com/p/android/issues/detail?id=194265">https://code.google.com/p/android/issues/detail?id=194265</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43903ab19de" width="1" height="1" alt=""><hr><p><a href="https://medium.com/android-dev/checkedtextview-does-not-save-its-state-43903ab19de">CheckedTextView does not save its state.</a> was originally published in <a href="https://medium.com/android-dev">Android Dev</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>