Click here to Skip to main content
12,629,039 members (35,171 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: Java Eclipse
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.
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 6-Dec-12 3:10am
Updated 6-Dec-12 3:29am
TorstenH.34.9K
v2

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161205.3 | Last Updated 6 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100