Frage

This question relates to Android development on Intellij IDEA 13 or Android Studio.

I created a very simple custom View:

public class CustomView extends View{

    public CustomView(Context context, AttributeSet attrs) {
        super(context, attrs);

        Log.i("TAG", "Hello Preview!");
    }
}

I then embedded it into a layout:

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

    <com.example.myapplication.app.CustomView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#FFFF00"/>

</FrameLayout>

I can now see the view in the layout preview window:

enter image description here

If I ran the app on a device or emulator, I would expect to see the text "Hello Preview!" in the logcat window, but if I use preview mode, the log is empty:

enter image description here

Is there any way to log output from a custom view running in preview mode? I don't want run the app on a device or emulator just to see the log output from a view.

I don't care if the solution involves Log.i. You could suggest some other logging function or even a custom plugin or library.

War es hilfreich?

Lösung

There's no device connected so no one sends Log.i to you. If you run the program on emulator or on a phone the output will be there

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top