title: Setting the ImageButton as invisible and retaining it when home/back Button of the phone is pressed or orientation changes is not working?
body: <p>In my application I have a ImageButton inside an EditText. When the ImageButton is clicked In my application I have a ImageButton inside an EditText. When the ImageButton is clicked I make it invisible using VIEW.GONE and enter some text in the EditText. I want to retain the ImageButton as invisible when the home button,back button of the phone is pressed and also when the orientation is changed. Can someone please help me, how this can be done?</p>
  
  <p>Here is part of the code:</p>
  
  <p>In Oncreate method: </p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_flip_card);
      edt_aroundMsg = (EditText) findViewById(R.id.edt_aroundMsg);
      if(savedInstanceState!=null){
          onRestoreInstanceState(savedInstanceState);
      }
        }
  </code></pre>
  
  <p>ImageButton onClickListener:</p>
  
  <pre><code>btn_msg_tap = (ImageButton) findViewById(R.id.btn_msg_tap);
      btn_msg_tap.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
  
              btn_msg_tap.setVisibility(View.GONE);
              edt_aroundMsg.setPadding(20, 10, 0, 0);
              edt_aroundMsg.setEnabled(true);
              // edt_aroundMsg.setFocusableInTouchMode(true);
              edt_aroundMsg.requestFocus();
              InputMethodManager im = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
              im.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
  
          }
      });
  </code></pre>
  
  <p>In onSaveInstanceState and onRestoreInstanceState method:</p>
  
  <pre><code>@Override
  protected void onSaveInstanceState(Bundle outState) {       
      super.onSaveInstanceState(outState);
      outState.putString("message", edt_aroundMsg.getText().toString());
      outState.putInt("font_size", font_size);
      outState.putBoolean("edt_msg_enabled", edt_aroundMsg.isEnabled());
      //outState.putByte("font_style", tf);
  }
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
      super.onRestoreInstanceState(savedInstanceState);
      edt_enabled = savedInstanceState.getBoolean("edt_msg_enabled");
      /*if (edt_enabled == true){
          btn_msg_tap.setVisibility(View.INVISIBLE);
      }
      else{
          btn_msg_tap.setVisibility(View.VISIBLE);
      }*/
      str_edtMsg = savedInstanceState.getString("message");
      font_size = savedInstanceState.getInt("font_size");
      edt_aroundMsg.setText(str_edtMsg);
      edt_aroundMsg.setTextSize(font_size);
  
  }
  </code></pre>
  
  <p>I may be missing something,due to my inexperience I am having difficulty in solving this problem. Please help me asap. Thanks.</p>