简体   繁体   中英

print on console in android studio

I want to know where the output of System.out.printf will be shown in Android Studio

package com.example.kakashi.gesture1;

import android.support.v4.view.MotionEventCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }

  public void printSamples(MotionEvent event){
    int historySize = event.getHistorySize();
    int pointerCount = event.getPointerCount();
    for (int i=0;i<historySize;i++) {
      System.out.printf("At time %d",event.getHistoricalEventTime(i));
      for (int p=0;p<pointerCount;p++){
        System.out.printf("pointer %d ( %f,  %f                                                                             )",event.getPointerId(p),event.getX(p),event.getY(p));
      }
    }
  }
}

You can see the println statements in Run window as shown below screenshot. so you can see the prinln statements in that window.

For example if I wanna see Strings which are in for loop then:

在此处输入图片说明

In the bottom of Android Studio IDE there is Android Monitor . Click it.

Then you can check your System.out.printf output in logcat tab there. Play around with list of Debug , Error , Info , etc.

如果您使用的是System.out.printf ,它将显示在android studio控制台中,但是如果您使用的是Log.e(...)等等,则将显示在logcat中。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM