首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在logCat中查看日志网段

在logCat中查看日志网段
EN

Stack Overflow用户
提问于 2012-04-23 03:22:26
回答 1查看 258关注 0票数 0

我想要一点帮助。

我正在尝试提取“触摸”信息并发送它。对于debug,我想打印到我提取到日志中的信息。我使用了Log.v,但它不起作用。每次我触摸屏幕时,我都会看到新的消息,但并不是我写的内容。我想我的视图定义有问题。我想定义所有的屏幕。附件是我的代码和日志消息。

代码语言:javascript
复制
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@40877448 }
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@40877448 }
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@40877448 }
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@413643e0 }
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@413643e0 }
>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 >obj=android.net.wifi.WifiStateMachine$StateChangeResult@413643e0 }
EN

回答 1

Stack Overflow用户

发布于 2012-04-23 04:48:41

我认为您的问题出在for循环声明中。

代码语言:javascript
复制
 for (i = 0; i < len - 1; i++) 

如果你的len是1,那么这个循环的主体将永远不会被执行,不是吗?只需将其更改为:

代码语言:javascript
复制
 for (i = 0; i < len; i++)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10271271

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档