提示到Android:Android的变化时,不会显示在Android的EDITTEXT文本文本 [英] Text not displayed in Android editText when changing android:hint to android:text
问题描述
我试图改变
android:hint="@string/prompt_code"
到
android:text="@string/prompt_code"
..但每当我改变提示成文本,该文本不是在应用程序中显示。如果我不改变暗示,是没有问题的。我可以改变的字符串值即prompt_ code中的文本(strings.xml中内)。这里有什么问题吗?所有我想要做的是改变提示text..can我做到这一点?
.. But whenever i change hint into text, the text is not displaying in the app. If i don't change "hint", there is no problem. And i can change the text in the string value ie, prompt_code(inside the strings.xml). What is the problem here? All i want to do is to change the hint to text..can i do this?
下面是XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:gravity="center_horizontal" android:layout_gravity="center" android:orientation="vertical" android:id="@id/login_status_code" android:visibility="gone" android:layout_width="wrap_content" android:layout_height="wrap_content">
<ProgressBar android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="8.0dip" style="?android:attr/progressBarStyleLarge" />
<TextView android:textAppearance="?android:textAppearanceMedium" android:id="@id/login_status_message_code" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginBottom="16.0dip" android:text="@string/login_progress_signing_in" android:fontFamily="sans-serif-light" />
</LinearLayout>
<ScrollView android:id="@id/login_form_code" android:background="#ff1a1a1a" android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">
<LinearLayout android:orientation="horizontal" android:background="#ff0099cc" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:textAppearance="?android:textAppearanceLarge" android:textStyle="bold" android:textColor="#ffffffff" android:gravity="center" android:layout_gravity="center" android:id="@id/textView5" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10.0dip" android:layout_marginBottom="10.0dip" android:text="Verify Code" />
</LinearLayout>
<TextView android:textAppearance="?android:textAppearanceLarge" android:textStyle="bold" android:textColor="#ffd3d3d3" android:gravity="center" android:layout_gravity="center" android:id="@id/textView2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="20.0dip" android:layout_marginBottom="20.0dip" android:text="Enter Your Code" />
<EditText android:textColor="#ffd3d3d3" android:id="@id/phonenum_code" android:background="@drawable/box1profile" android:paddingLeft="10.0dip" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="20.0dip" android:layout_marginRight="20.0dip" android:hint="@string/prompt_code" android:maxLines="1" android:singleLine="true" android:inputType="phone" />
<Button android:layout_gravity="center" android:id="@id/sign_in_button_code" android:background="@drawable/codesubmit" android:paddingLeft="32.0dip" android:paddingRight="32.0dip" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="16.0dip" />
</LinearLayout>
</ScrollView>
推荐答案
好吧,复制你的XML code为刚刚的EditText(ID为phoneum_ code)后,我测试过更改行
Ok, after copying your XML code for just the EditText (with id phoneum_code), I've tested changing the line
android:hint="@string/prompt_code"
到
android:text="@string/prompt_code"
它的工作与我在prompt_ code字符串输入的任何文字,为提示和文本。
It worked with any text I entered in the prompt_code string, for both hint and text.
我有你在这个特殊的EditText文本某处在code,这将覆盖在你的XML声明的值设置为空字符串的感觉。
I have the feeling you're setting the text in this particular EditText to an empty string somewhere in your code, which overwrites any value that was declared in your XML.
您要检查使用此EditText上的code和验证,如果它不叫的setText();
在某一点上的EditText对象
You want to check the code that uses this EditText and verify if it's not calling setText("");
on the edittext object at some point.
这篇关于提示到Android:Android的变化时,不会显示在Android的EDITTEXT文本文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!