听所使用kotlin就可以不用findviewbyid来找控件了,小生迫不及待的尝试了一下,结果。。。没仔细看官方文档,经验不足,掉坑里了
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.miracle.kotlindemo.MainActivity">
<TextView
android:id="@+id/tv" //添加一个id
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_co