2013-06-20 25 views
1

鳥瞰圖不工作

我試圖使用三星Galaxy S4的新功能鳥瞰圖,特別是onHover選項事件。我已經擁有它的...銀河S4:onHover選項/鳥瞰圖的輸入法並不INPUTMETHOD工作

  • 目標API級別17
  • 工作正常的應用程序提供onHover選項事件偵聽器
  • 設置意圖過濾器com.sec.android.airview.HOVER

現在我想用它作爲輸入法。我的問題是輸入法的觀點沒有得到任何onHover選項的事件,即使我還設置了鳥瞰圖的意圖過濾器:

AndroidManifest.xml中的摘錄:

<application android:label="@string/ime_name" 
    <service android:name="com.example.keyboard" 
     android:permission="android.permission.BIND_INPUT_METHOD"> 
     <intent-filter> 
      <action android:name="android.view.InputMethod" /> 
     </intent-filter> 
     <intent-filter> 
      <action android:name="com.sec.android.airview.HOVER" /> 
     </intent-filter> 
     <meta-data android:name="android.view.im" android:resource="@xml/method" /> 
    </service> 
</application> 

目前我有一個簡單的LinearLayout一個按鈕在我的輸入方法的佈局:

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    > 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Hover Button" 
     android:id="@+id/hoverbutton2"/> 

</LinearLayout> 

的事件監聽器被設置這樣的:

Button hoverButton = (Button) mInputView.findViewById(R.id.hoverbutton2); 
hoverButton.setOnHoverListener(new View.OnHoverListener() { 
    @Override 
    public boolean onHover(View v, MotionEvent event) { 
     Log.d(TAG, "hoverButton2: onHover"); 
     return false; 
    } 
}); 

以相同方式設置的onClick偵聽器按預期工作。

任何指針?

回答

1

我有同樣的問題。我發現發表furbyx92在XDA開發的解決方案:

  1. 第一件事情就是要確保在設備在鳥瞰圖設置爲ON與所有subsettings ON以及設置。

  2. 下一頁Android清單:

    <application 
        android:allowBackup="true" 
        android:icon="@drawable/ic_launcher" 
        android:label="@string/app_name" 
        android:theme="@style/AppTheme" > 
        <meta-data 
         android:name="com.sec.android.airview.enable" 
         android:value="true" /> 
        <intent-filter> 
         <action android:name="com.sec.android.airview.HOVER" /> 
        </intent-filter> 
        <activity 
         android:name="edu.uanl.secondapp.MainActivity" 
         android:label="@string/app_name" > 
         <intent-filter> 
          <action android:name="android.intent.action.MAIN" /> 
          <category android:name="android.intent.category.LAUNCHER" /> 
         </intent-filter> 
         <intent-filter> 
          <action android:name="com.sec.android.airview.HOVER" /> 
         </intent-filter> 
        </activity> 
    </application> 
    
  3. 在您的代碼:

    textView.setOnHoverListener(new View.OnHoverListener() { 
        @override 
        public boolean onHover(View view, MotionEvent motionEvent) { 
         switch(motionEvent.getAction()){ 
          case MotionEvent.ACTION_HOVER_ENTER : // Enter Hovered 
          case MotionEvent.ACTION_HOVER_EXIT: // Leave Hovered 
           view.setBackgroundColor(Color.TRANSPARENT); 
           view.setScaleX((float)1.0); 
           view.setScaleY((float)1.0); 
           break; 
          case MotionEvent.ACTION_HOVER_MOVE: // On Hover 
           view.setBackgroundColor(Color.RED); 
           view.setScaleX((float)2.0); 
           view.setScaleY((float)2.0); 
           break; 
         } 
         Log.wtf("Something", "I'm Being Hovered" + motionEvent.getAction()); 
         return false; 
        } 
    }); 
    textView.setHovered(true); 
    
+0

這正是我會爲** **應用程序做的,但我想從**輸入法**中獲取懸停事件。除此之外,您在AndroidManifest.xml中設置了兩次intent過濾器。我相信申請中的申請是不必要的。 – Frederic