2012-04-22 5 views
0

私はlittelヘルプをしたいと思います。ログメッセンジャーをlogCatで見る

私は "タッチ"情報を抽出して送信するつもりです。デバッグのために私はログに抽出した情報に印刷したい。私はLog.vを使用していて動作しません。私が画面に触れるたびに、私は新しいメッセージを見ますが、私が書いたものはありません。私は私のビューの定義に問題があると思います。 私はすべての画面を定義したいと思います。 が私のコードとログメッセージです。

>1. "TouchScreen.java" 
    public class TouchScreenActivity extends Activity { 
     /** Called when the activity is first created. */ 
     View mButtonLable; 

     @Override 
     public void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.main); 

      mButtonLable = findViewById(R.id.super_view); 
      mButtonLable.setOnTouchListener(new View.OnTouchListener() { 
      @Override 
      public boolean onTouch(View view, MotionEvent motionEvent) { 
      int i, len, id; 
      float x, y, t; 

      len = motionEvent.getPointerCount(); 
      float[][] touch = new float[len][4]; 
      for (i = 0; i < len - 1; i++) { 
        id = motionEvent.getPointerId(i); 
        x = motionEvent.getX(i); 
        y = motionEvent.getY(i); 
        t = motionEvent.getEventTime(); 
        touch[i][0] = x;* 
        touch[i][1] = y; 
        touch[i][2] = id; 
        touch[i][3] = t; 
        Log.v("TouchScreenActity", "x = " + x + ", y = " + y 
        + ", id = " + id + ",t = " + t); 
       } 

       return false; 
      } 

     }); 


    } 

    >2."main.xml: 
    <?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" 
     android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> 

     <TextView 
      android:id="@+id/super_view" 
      android:layout_width="fill_parent" 
      android:layout_height="0dip" 
      android:layout_weight="2" 
      android:background="#f00" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/hello" /> 

    </LinearLayout> 

my Logcat 
>04-18 23:46:52.390: D/HierarchicalStateMachine(301): processMsg: SupplicantStartedState 
>04-18 23:46:52.390: D/WifiStateMachine(301): SupplicantStartedState{ what=65574 when=-19ms } 
>04-18 23:46:52.390: I/wpa_supplicant(19652): SCAN_RESULTS : [2] 
>04-18 23:46:52.400: D/HierarchicalStateMachine(301): handleMessage: X 
>04-18 23:46:52.400: D/HierarchicalStateMachine(301): handleMessage: E msg.what=65575 
>04-18 23:46:52.400: D/HierarchicalStateMachine(301): processMsg: DisconnectedState 
>04-18 23:46:52.400: D/WifiStateMachine(301): DisconnectedState{ what=65575 when=-17ms >[email protected] } 
>04-18 23:46:52.400: D/WifiStateMachine(301): setDetailed state, old =SCANNING and new >state=CONNECTING 
>04-18 23:46:52.400: D/HierarchicalStateMachine(301): processMsg: ConnectModeState 
>04-18 23:46:52.400: D/WifiStateMachine(301): ConnectModeState{ what=65575 when=-18ms >[email protected] } 
>04-18 23:46:52.400: D/HierarchicalStateMachine(301): handleMessage: X 
>04-18 23:46:52.400: D/WpsStateMachine(301): InactiveState{ what=65575 when=-1ms >[email protected] } 
>04-18 23:46:52.460: I/wpa_supplicant(19652): Wireless event: new AP: 00:21:27:f5:3d:20 
>04-18 23:46:52.460: I/wpa_supplicant(19652): CTRL-EVENT-STATE-CHANGE id=4 state=4 >BSSID=00:21:27:f5:3d:20 
>04-18 23:46:52.460: V/WifiMonitor(301): Event [CTRL-EVENT-STATE-CHANGE id=4 state=4 >BSSID=00:21:27:f5:3d:20] 
>04-18 23:46:52.460: D/HierarchicalStateMachine(301): handleMessage: E msg.what=65575 
>04-18 23:46:52.460: D/HierarchicalStateMachine(301): processMsg: DisconnectedState 
>04-18 23:46:52.470: I/wpa_supplicant(19652): Current ps mode is 0 
>04-18 23:46:52.470: I/wpa_supplicant(19652): Associated with 00:21:27:f5:3d:20 
>04-18 23:46:52.470: I/wpa_supplicant(19652): CTRL-EVENT-STATE-CHANGE id=4 state=7 >BSSID=00:00:00:00:00:00 
>04-18 23:46:52.470: D/WifiStateMachine(301): DisconnectedState{ what=65575 when=-1ms >[email protected] } 
>04-18 23:46:52.470: I/wpa_supplicant(19652): CTRL-EVENT-CONNECTED - Connection to >00:21:27:f5:3d:20 completed (reauth) [id=4 id_str=] 
>04-18 23:46:52.470: D/WifiStateMachine(301): setDetailed state, old =CONNECTING and new >state=CONNECTING 
>04-18 23:46:52.470: D/HierarchicalStateMachine(301): processMsg: ConnectModeState 
>04-18 23:46:52.470: D/WifiStateMachine(301): ConnectModeState{ what=65575 when=-2ms >[email protected] } 
>04-18 23:46:52.470: D/HierarchicalStateMachine(301): handleMessage: X 
>04-18 23:46:52.470: D/WpsStateMachine(301): InactiveState{ what=65575 when=-1ms >[email protected] } 

答えて

0

あなたの問題はforループ宣言にあると思います。

for (i = 0; i < len - 1; i++) 

lenが1の場合、このサイクルの本体は決して実行されません。次のように変更してください:

for (i = 0; i < len; i++) 
関連する問題