问题
I have simple Login page with some textview and edittex and i set static text to textview and hint to edittext from string.xml working fine.
But Now
i am receiving that strings(which i set form stirng.xml as i explained above) form webservices and i have to set webservice string.
Issue is i didn't set any id to that login screen elements(edittext and textview).
Update
I have AppCompatTextView like below in my XML
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/_20sdp"
android:gravity="center"
android:text="@string/login_text_welcome"
android:textColor="@color/colorTextLightGrey"
android:textSize="@dimen/textview_size_medium"
android:textStyle="bold" />
I want to settext to above AppCompatTextView without ID.
Is it possible to setText to textview and edittext without setting any id?
回答1:
Just include android:id="@+id/textView1 in your XML to set ID of an element.
回答2:
You can use findViewByName
rather than findViewById
and then continue with your code.
来源:https://stackoverflow.com/questions/64714568/android-appcompatedittext-appcompattextview-settext-without-id