title: Algorithm for my project in android
body: <p>I have a android project that generates random numbers as the button's text. If you click a button the value of the corresponding button should be displayed in the edittext.</p>
  
  <p>I am already getting the value of the buttons and also able to display it in the edittext. I have 12 buttons and 2 edittexts. What I want is, if I will do the first click then first value will display in the first edittext and in the second click the value will display in the second edittext. </p>
  
  <p>My problem is that in the first click the value is getting displayed in the 2 edittexts simultaneously. Hope you can help me, here is my code:</p>
  
  <pre><code>b1=(Button)findViewById(R.id.b1);
      et1=(EditText)findViewById(R.id.first);
      et2=(EditText)findViewById(R.id.second);
      b1.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              str=((Button)v).getText().toString();
              et1.setText(str);
              et2.setText(str);
          }
      });
  </code></pre>
  
  <ul>
  <li><code>b1</code> = one of the buttons. </li>
  <li><code>et1</code> and <code>et2</code>= the two edittexts.</li>
  <li>str = empty string</li>
  </ul>