Click here to Skip to main content
16,018,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hello, I am developing a simple application of send message
my design should be a same as which is in android phones.I have 3 Edit text, one button and keyboard.My problem is I dont know how to make focus to say if edit text1 is focused then the text which on edit text3 wil be there by clicking on button else if edit text2 is focused then the text which on edit text3 wil be on edit text2.
I used this but it dose not work and there is no error.
Java
public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_nada_saif_70126172);

      Button bq=(Button)findViewById(R.id.button2);

      EditText et1=(EditText)findViewById(R.id.editText1);
      EditText et2=(EditText)findViewById(R.id.editText2);
      final EditText et3=(EditText)findViewById(R.id.editText3);


      if (et2.requestFocus())
      {
          bq.setOnClickListener(new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  et3.setText(et3.getText()+"q");
                  final EditText et2=(EditText)findViewById(R.id.editText2);
                  Button bsend=(Button)findViewById(R.id.button1);
                  bsend.setOnClickListener(new View.OnClickListener() {

                      @Override
                      public void onClick(View v) {
                          // TODO Auto-generated method stub
                          et2.setText(et3.getText());

                                                  }
                                                                      });

                                          }
                                                          });
      }
       else
           //if

      // (et1.requestFocus())

      bq.setOnClickListener(new View.OnClickListener() {

          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              et3.setText(et3.getText()+"q");
              final EditText et1=(EditText)findViewById(R.id.editText1);
              Button bsend=(Button)findViewById(R.id.button1);
              bsend.setOnClickListener(new View.OnClickListener() {

                  @Override
                  public void onClick(View v) {
                      // TODO Auto-generated method stub
                      et1.setText(et3.getText());

                                              }
                                                                  });

                                      }
                                                      });
Posted
Updated 6-Dec-12 2:29am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900