此问题与Intellij IDEA 13或Android Studio上的Android开发有关。
我创建了一个非常简单的自定义视图:
public class CustomView extends View{
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
Log.i("TAG", "Hello Preview!");
}
}
然后我将其嵌入到布局中:
<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>
我现在可以在布局预览窗口中看到该视图:
如果我在设备或模拟器上运行应用程序,我希望看到文本&#34; Hello Preview!&#34;在logcat窗口中,但如果我使用预览模式,则日志为空:
有没有办法记录在预览模式下运行的自定义视图的输出?我不想在设备或模拟器上运行应用程序只是为了查看视图中的日志输出。
如果解决方案涉及Log.i,我不在乎。您可以建议一些其他日志记录功能,甚至是自定义插件或库。
答案 0 :(得分:1)
没有设备连接,因此没有人向您发送Log.i
。如果您在模拟器或手机上运行程序,输出将在那里