2011-10-03 87 views
1

說我有一個InputService(鍵盤)啓動一個活動。由於該活動具有透明背景,因此可以看出,該活動正在進行。一旦活動開始,鍵盤將隱藏起來並在活動結束後保持隱藏狀態。如何防止鍵盤被隱藏?

如何防止隱藏?

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

回答

1

只是這樣做:

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

不,不是我真正想到的。 :)它使鍵盤出現在我的新活動上,但我需要防止它從我的新活動中消失。 – Roger

+0

最適合我的是Android Manifest中適合您的活動。 android:windowSoftInputMode =「stateVisible」 – Uttam

+0

感謝您的輸入,鍵盤應該保持UNDER新的活動,而不是它。 – Roger

-1

我在完全相同的問題擱淺:-(你同時找到了解決辦法

我試圖以編程方式打開鍵盤?再次回到最初的活動並在TextView上模擬touchevent,以使TextView再次綁定到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(); 

這工作,如果我知道用戶點擊了哪個TextView。有沒有辦法在InputMethodService類中查找綁定的TextView的相關位置?與位置我的意思是X和Y座標模擬在該位置touchevent。