Android AppCompatEditText,AppCompatTextView,不带ID的setText [英] Android AppCompatEditText,AppCompatTextView, setText without ID

查看:161
本文介绍了Android AppCompatEditText,AppCompatTextView,不带ID的setText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的登录页面,其中包含一些textview和edittex,我将静态文本设置为textview,并提示从string.xml到edittext正常工作.

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.

但是现在

我正在接收来自Web服务的字符串(如上所述,我将其设置为stirng.xml),而我必须设置Webservice字符串.

i am receiving that strings(which i set form stirng.xml as i explained above) form webservices and i have to set webservice string.

问题是我没有为登录屏幕元素(edittext和textview)设置任何ID.

Issue is i didn't set any id to that login screen elements(edittext and textview).

更新

我的XML中具有如下所示的AppCompatTextView

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" />

我想将文本设置为不带ID的上述AppCompatTextView.

I want to settext to above AppCompatTextView without ID.

是否可以在不设置任何ID的情况下将Text设置为textview和edittext?

推荐答案

您可以使用 findViewByName 而不是 findViewById ,然后继续执行代码.

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

这篇关于Android AppCompatEditText,AppCompatTextView,不带ID的setText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆