-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?

Arbaz.in
  • 1,478
  • 2
  • 19
  • 41

2 Answers2

1

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

  • 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 https://stackoverflow.com/questions/6831506/find-view-by-name/31042515 – khaled al-saffarini Nov 06 '20 at 13:31
0

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

Priyaank
  • 141
  • 6