Is it possible to assign a key press code to the press on an Android button?
<p>I have been working on passing an edit text value to a string so I can upload the input to my database, but after a lot of time working I have figured out how to do this by pressing enter on the keyboard. I also have a button for uploading the string and I want to have only the button involved, so the upload button will be enter also.</p>

<p>Here is my button:</p>

<pre><code>    submit.setOnClickListener(new View.OnClickListener(){

            public void onClick(View v) {

                postData();
            }

        });
</code></pre>

<p>Here is the key press enter command:</p>

<pre><code>    enter.setOnKeyListener(new View.OnKeyListener() {
              public boolean onKey(View view, int keyCode, KeyEvent event) {
                if (keyCode == KeyEvent.KEYCODE_ENTER) {
                  name = enter.getText().toString();
                  return true;
                }
                return false;
              }
            });
</code></pre>

<p>Here is where I am using the converted string called name:</p>

<pre><code>     nameValuePairs.add(new BasicNameValuePair("username", name));
</code></pre>

<p>So I want to get rid of the need for the user to press enter before pressing the submit button, so pressing upload will take care of the enter key press code. I tried creating a method to simulate this being pressed but it didn't work, and researching didn't show me a possible way to assign a key press to a button on click.</p>

<p>Any suggestions would be appreciated.</p>

<p>Thanks.</p>
