-1

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?

2 Answers 2

1

You can use findViewByName rather than findViewById and then continue with your code.

Sign up to request clarification or add additional context in comments.

1 Comment

you have to find views by identifier when dealing with XML int id = getResources().getIdentifier(name, "id", context.getPackageName()); View view = findViewById(id); you can find more on this link stackoverflow.com/questions/6831506/find-view-by-name/31042515
0

Just include android:id="@+id/textView1 in your XML to set ID of an element.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.