开发者

how to prevent keyboard from hiding?

开发者 https://www.devze.com 2023-04-10 12:52 出处:网络
Say I have an InputService ( keyboard ) that starts an activity. Since the activity has a transparent background, it is see开发者_运维知识库n, that going on under it. Once the activity starts, the key

Say I have an InputService ( keyboard ) that starts an activity. Since the activity has a transparent background, it is see开发者_运维知识库n, that going on under it. Once the activity starts, the keyboard hides from under it and remains hidden after the activity has ended.

How to I prevent it from hiding?

Intent PopIntent = new Intent(getBaseContext(), popup.class);
PopIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplication().startActivity(PopIntent);


Just do this:

//Show soft-keyboard:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);


i'm stranded at the exactly the same problem :-(. did you meanwhile found a solution?

i tried to open the keyboard programmatically again after i come back to the originally activity and simulate a touchevent on the TextView so that the TextView is bound again to the InputMethodService:

Runnable r = new Runnable() {

                @Override
                public void run() {
                    final Instrumentation inst = new Instrumentation();
                    int[] location = new int[2];
                    tvEdit1.getLocationOnScreen(location);
                    long time1 = SystemClock.uptimeMillis();
                    long time2 = SystemClock.uptimeMillis();
                    MotionEvent mv = MotionEvent.obtain(time1, time2, MotionEvent.ACTION_DOWN,
                            location[0], location[1], 0);
                    inst.sendPointerSync(mv);

                    time1 = SystemClock.uptimeMillis();
                    time2 = SystemClock.uptimeMillis();
                    mv = MotionEvent.obtain(time1, time2, MotionEvent.ACTION_UP,
                            location[0], location[1], 0);

                    inst.sendPointerSync(mv);

                }
            };    

            Thread t = new Thread(r);
            t.start();

That works if i know which TextView the user clicked. Is there a way to find in a InputMethodService Class the correlating position of the bound TextView? With position i mean the x und y coordinates for simulating a touchevent on that position.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号