我无法通过单击Android Studio中的按钮来获取日志事件

时间:2019-08-01 15:25:15

标签: android android-studio button

我尝试在Android Studio中使用onClick函数创建两个对接。但是我无法在日志事件面板中看到它们的状态。

以下是图片:App Image

这是代码:-

package com.example.demoap;

import androidx.appcompat.app.AppCompatActivity;

import android.util.Log;
import android.view.View;

import android.os.Bundle;

public class MainActivity extends AppCompatActivity {

    public void clickFunction(View view) 
    {
        Log.i("Info", "Congratulations, button pressed!");
    }
    public void clickFunction1(View view) 
    {
        Log.i("Info", "Congratulations,2 button pressed!");
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }
}

这是我运行项目并单击两个按钮时得到的。

20:42   IDE and Plugin Updates: Android Studio is ready to update.
20:42   Gradle sync started
20:43   Project setup started
20:43   Gradle sync finished in 39 s 529 ms (from cached state)
20:43   Source generation ended in 1 s 705 ms
20:45   * daemon not running; starting now at tcp:5037
20:45   * daemon started successfully
20:45   Executing tasks: [:app:assembleDebug]
20:45   Gradle build finished in 6 s 81 ms
20:46   Emulator: Process finished with exit code 0

1 个答案:

答案 0 :(得分:1)

确保您正在查看正确的日志。 打开日志。

Enable Logcat from here

确保正在查看信息日志。

enter image description here