title: Use an EditText with custom keyboard
body: <p>I am new to android. I am trying to create an application with a custom keyboard, used for the application only. Not a general keyboard for distribution. Basically my test is to have a layout like:</p>
  
  <pre><code>Relative Layout
       Relative Layout id tolayouot
           EditText id userID
           Button
       LinearLayout alignbottomparent=TRUE
  
           InputMethodService.KeyboardView  id kv
  </code></pre>
  
  <p>So there is a top section with an Edit Box and a button and the bottom section is the keyboard.  When I press the button, the Custom Keyboard appears. Then I would like to be able to type into the EditText box.</p>
  
  <p>I have made a private variable to implement keyboardactionlistener. It basically follows and example and only puts Log messages out.</p>
  
  <pre><code>private OnKeyboardActionListener mykal = new OnKeyboardActionListener() 
  { 
  
    @Override
    public void swipeUp() {
            Log.d(TAG, "swipeUp");
    }
  
    @Override
    public void swipeRight() {
            Log.d(TAG, "swipeRight");
    }
  
    @Override
    public void swipeLeft() {
            Log.d(TAG, "swipeLeft");
    }
  
    @Override
    public void swipeDown() {
            Log.d(TAG, "swipeDown");
    }
  
    @Override
    public void onText(CharSequence text) {
            Log.d(TAG, "onText? \"" + text + "\"");
    }
  
    @Override
    public void onRelease(int primaryCode) {
            Log.d(TAG, "onRelease? primaryCode=" + primaryCode);
    }
  
    @Override
    public void onPress(int primaryCode) {
            Log.d(TAG, "onPress? primaryCode=" + primaryCode);
    }
  
    @Override
    public void onKey(int primaryCode, int[] keyCodes) {
  
            Log.d(TAG, "onKey? primaryCode=" + primaryCode);
            int n1 = 0; // -1 count
            for (int keyCode : keyCodes) {
                    if (keyCode == -1) {
                            n1++;
                            continue;
                    }
                    Log.v(TAG, "keyCode=" + keyCode);
            }
            Log.v(TAG, "keyCode=-1 *" + n1);
             }
  
  };
   }
  </code></pre>
  
  <p>Here is the on create code </p>
  
  <pre><code>   public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_login_example);
          Button b = (Button) this.findViewById(R.id.tstbtn);
          myedit  = (EditText) this.findViewById(R.id.user_ID);
          rl  = (RelativeLayout) this.findViewById(R.id.toplayout);
                  b.setOnClickListener(clistner);
          KeyboardView keyboardView = (KeyboardView) findViewById(R.id.keyboardView);
          Keyboard keyboard = new Keyboard(this, R.xml.tstkbd);
          keyboardView.setKeyboard(keyboard);
          keyboardView.setEnabled(true);
          keyboardView.setPreviewEnabled(true);
          myedit.setOnTouchListener(mytouch);
   //       keyboardView.setOnKeyListener(this);
          keyboardView.setOnKeyboardActionListener(mykal);
          //hide the default keyboard
          getWindow().setSoftInputMode(
                  WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
  
  
     }
  </code></pre>
  
  <p>So when I run my test, the default keyboard disappears just like I want, I click the button and my keyboard appears. All of the log messages in the keyboardactionlistener show up in the debugger when I press the keys, so the keyboard is working. I can set the focus to the EditText but if I click a key on my custom keyboard, I do not get any text in the EditText box.</p>
  
  <p>Is there a way to smoothly get the keypresses from the custom keyboard to register in the EditText box?</p>
  
  <p>I know I can use the OnKey Event of the KeyBoardactionListener to manipulate the text in the EditText box but I would like to use an intrinsic function.</p>
  
  <p>I have tried:</p>
  
  <ol>
  <li>Sending an Event Message to the EditText and to the RelativeLayout toprl but that crashed.</li>
  <li>Setting an onTouchListener for the EditText.</li>
  </ol>
  
  <p>Is the only way to accomplish this to create an InputMethodService?</p>
  
  <p>Can anyone please explain why this doesnt work???</p>
  
  <p>The two examples below were the ones I was trying to use.</p>
  
  <p><a href="http://androidpadanam.wordpress.com/2013/05/29/customkeyboard-example/" rel="nofollow">http://androidpadanam.wordpress.com/2013/05/29/customkeyboard-example/</a>
  <a href="http://www.infiniterecursion.us/2011/02/android-activity-custom-keyboard.html" rel="nofollow">http://www.infiniterecursion.us/2011/02/android-activity-custom-keyboard.html</a></p>