Overriding on backkeypressed and set layout visibility to gone
<p>I want to set the visibility of a relativeLayout to gone when i press back key. With intents overriding on back key works fine but when i try it with view.gone my views doesn't dissapear. Do i miss a step ? Here is my code.
@Override</p>

<pre><code>public void onBackPressed() {

    // TODO Auto-generated method stub

    if (main_layout.getVisibility() == View.VISIBLE &amp;&amp; 

        sub_layout.getVisibility() == View.GONE) {


        finish();

    } else if (sub_layout.getVisibility() == View.VISIBLE &amp;&amp; 

              main_layout.getVisibility() == View.VISIBLE){

        boutton_radio.setVisibility(View.VISIBLE);

        boutton_radio.setEnabled(true);

        boutton_retour.setVisibility(View.GONE);

        boutton_retour.setEnabled(false);

        sub_layout.setEnabled(false);

        sub_layout.setVisibility(View.GONE);

        main_layout.setVisibility(View.VISIBLE);

        main_layout.setEnabled(true);

    }

    return;
}
</code></pre>
