title: Android: why buttons event not working after press back button?
body: <p>I have defined four buttons that onclick event shows a content, now after click when press </p>
  
  <p><strong>back button</strong> that shows same four buttons but click event not working.<br>
  I defined a field that if user saw content isLooked=true so when clicked on back button I  setContentView(R.layout.index) and I will not allow to exit of current activity.<br>
  why not working events after click on back button?</p>
  
  <pre><code> private boolean isLooked = false;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          try {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.index);
              initialEvents();
          } catch (Exception e) {
              new com.example.csharp.Log.Error().Save(e);
          }
      }
  
      private void initialEvents() {
          View v = findViewById(R.id.btnChapter1);
          v.setOnClickListener(this);
          v = findViewById(R.id.btnChapter2);
          v.setOnClickListener(this);
          v = findViewById(R.id.btnChapter3);
          v.setOnClickListener(this);
          v = findViewById(R.id.btnChapter4);
          v.setOnClickListener(this);
      }
  
      @Override
      public void onBackPressed() {
          if (isLooked) {
              setContentView(R.layout.index);
              isLooked = false;
          } else {
              super.onBackPressed();
  
          }
      }
  
      @Override
      public boolean onKeyDown(int keyCode, KeyEvent event) {
          if (keyCode == KeyEvent.KEYCODE_BACK &amp;&amp; isLooked) {
              setContentView(R.layout.index);
              isLooked = false;
              return true;
          } else {
              return super.onKeyDown(keyCode, event);
          }
      }
  
      @Override
      public void onClick(View v) {
          switch (v.getId()) {
          case R.id.btnChapter1:
              setContentView(R.layout.chapter1_index);
              isLooked = true;
              break;
  
          case R.id.btnChapter2:
              setContentView(R.layout.chapter2_index);
              isLooked = true;
              break;
          case R.id.btnChapter3:
              setContentView(R.layout.chapter3_index);
              isLooked = true;
              break;
  
          case R.id.btnChapter4:
              setContentView(R.layout.chapter4_index);
              isLooked = true;
              break;
          }
      }
  </code></pre>