start EditText With Keyboard - Android User Interface

Android examples for User Interface:EditText

Description

start EditText With Keyboard

Demo Code


//package com.java2s;
import android.annotation.SuppressLint;

import android.os.Handler;

import android.os.SystemClock;
import android.view.MotionEvent;

import android.widget.EditText;

public class Main {
    @SuppressLint("Recycle")
    public static void startEditWithKeyboard(final EditText aText) {
        Handler handler = new Handler();
        handler.postDelayed(new Runnable() {
            public void run() {
                aText.requestFocus();/*from w ww.  j  ava 2  s.  c  o m*/
                aText.dispatchTouchEvent(MotionEvent.obtain(
                        SystemClock.uptimeMillis(),
                        SystemClock.uptimeMillis(),
                        MotionEvent.ACTION_DOWN, 0, 0, 0));
                aText.dispatchTouchEvent(MotionEvent.obtain(
                        SystemClock.uptimeMillis(),
                        SystemClock.uptimeMillis(), MotionEvent.ACTION_UP,
                        0, 0, 0));
                aText.setSelection(aText.length());
            }
        }, 60);
    }
}

Related Tutorials