Fragments: Button pressed state not being restored when pressing BACK
<p>I have a fragment embedded in a layout.  This fragment has a very simple view (basically just a styled button with its pressed state being programmatically set). </p>

<p>When I start a new activity from the activity hosting the fragment, and press BACK to go back to the original activity the button is still disabled, but is now showing its unpressed state.</p>

<p>layout.xml:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" &gt;

     &lt;fragment
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        class="com.mypackage.NavigationDrawerFragment"
        android:gravity="bottom"
        android:padding="5dp" /&gt;&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>fragment_layout.xml</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="#000000"
    android:orientation="horizontal"
    android:paddingLeft="20dp"
    android:paddingRight="20dp"
    android:paddingBottom="10dp" &gt;

    &lt;Button
            android:id="@+id/nav_home"
            style="@style/navigation_button"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@drawable/button_home"
            android:text="HOME"
            android:textColor="@drawable/button_text" /&gt;

&lt;/RelativeLayout&gt;
</code></pre>

<p>In the fragment class, I simply do the following:</p>

<ul>
<li>Disable the button</li>
<li>Set the pressed state of the button to true (so the downstate of the drawable is shown)</li>
</ul>

<p>My fragment class:</p>

<pre><code>public class NavigationDrawerFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {

        mDrawer = inflater.inflate(R.layout.fragment_navigation_drawer,
            container, false);
        mButtonHome = (Button) mDrawer.findViewById(R.id.nav_home);
        mButtonHome.setEnabled(false);
        mButtonHome.setPressed(true);
    }
}
</code></pre>

<p>Any idea why the enabled state of the button is preserved, but the pressed state is not?   </p>
