title: How to stop loop with button click
body: <p>how do i stop a loop with a button? </p>
  
  <p>onClick creates some dynamic checkboxes and in the loop i want to check if they are checked.</p>
  
  <p>this is the code i tried so far.</p>
  
  <p><em>edit: rephrasing question.</em> </p>
  
  <p>i need a loop which runs until the user presses a button, something like this</p>
  
  <p>while(!button.isPressed()){}</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) 
  {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragen);    
  
              View weiterButton = findViewById(R.id.weiterButton);
          weiterButton.setOnClickListener(this);    
  
  }
  
  
  
  public void onClick(View v) 
  {
          switch (v.getId()) {
          case R.id.weiterButton:
                   View weiterButton = findViewById(R.id.weiterButton);
                   weiterButton.setOnClickListener(this);
                   while(!weiterButton.isPressed())
                   {
                       // do things
                   }
             break;
  }
  </code></pre>