我有一个TextView,XML文件是Android Studio中无法看到的TextView ID
<TextView
android:layout_width="wrap_content"
android:layout_height="30dp"
android:fontFamily="sans-serif"
android:lineSpacingExtra="30sp"
android:text="MyText"
android:textColor="?android:attr/colorActivatedHighlight"
android:textSize="18sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.22000003" />
没有这个TextView中的ID,所以我不能在MainActivity.java使用它,我刚开始的Android工作室(我到目前为止与Python合作过)我错过了什么?
我也有一个按钮,它有一个ID。
你需要定义* ID *为*文本查看*?或者你需要在* Activity *中使用它? *详细说明*更多。 –
这个textview是默认的“Hello World!”所以我认为它默认必须有一个ID。 – GLHF
您需要手动将id定义为* android:id =“@ + id/tvTest”*作为* Text View *。 * tvTest *是* Text View *的标识符,您将在* Activity *中使用该标识符将一些数据绑定到它。 –