3

I was trying to change

android:hint="@string/prompt_code" 

into

android:text="@string/prompt_code"

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

here is the 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>

user3548321
  • 523
  • 2
  • 8
  • 18
  • set your `EditText` background as `NULL` and change `TextColor` to different try and also set `android:inputType="text"` – M D Apr 18 '14 at 09:48
  • i will try and report back.. – user3548321 Apr 18 '14 at 09:53
  • ya...i don't know what the problem is... can you please edit the xml for me and upload it in datafile host so that i can compare the two xml files or replace it?? here is the xml file http://datafilehost.com/d/ca0ee808 and by the way, i want to change the text inside the prompt_code(inside the strings.xml) value into number.. For example i want to change "Code" into "12345" – user3548321 Apr 18 '14 at 12:34
  • Ask the owner of the code for the source so that you can do it properly or download it if is open source. – Simon Sep 21 '14 at 16:01

2 Answers2

0

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" 

to

android:text="@string/prompt_code"

It worked with any text I entered in the prompt_code string, for both hint and text.

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.

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.

Smokez
  • 382
  • 1
  • 5
  • i should change the input type into what? – user3548321 Apr 18 '14 at 09:50
  • A phone number as input means that the EditText will not take characters as input that never appear in a phone number. I don't know what the value of @string/prompt_code is, but it might work when it only contains numbers. – Smokez Apr 18 '14 at 10:03
  • Still not working...The number is not shown in the text box..It's empty...Works if if i change it back to android:hint...can you please edit the xml for me and upload it in datafile host so that i can compare the two xml files or replace it?? here is the xml file http://www.datafilehost.com/d/ca0ee808 and by the way, i want to change the text inside the prompt_code(inside the strings.xml) value into number.. For example i want to change "Code" into "12345" – user3548321 Apr 18 '14 at 12:05
  • there is text in the prompt_code string and it is coming up if i use android:hint, but nothing when using android:text.. – user3548321 Apr 18 '14 at 13:14
  • this is the value in the string>>>> Your code and i can change "Your code" to whatever i want it will show if i use android:hint but empty when using android:text... – user3548321 Apr 18 '14 at 13:17
  • i don't understand why it's missing when i use android:text – user3548321 Apr 18 '14 at 13:20
  • And it should not be empty, since it just works when you set it as text. This means that the text you set in the XML is overwritten somewhere in the Activity or Fragment that uses the EditText. – Smokez Apr 18 '14 at 13:22
  • ok..one more help..to make sure that it's not a problem of the xml file, can you edit it and upload it as an xml file?? Thanks for the help.. – user3548321 Apr 18 '14 at 13:25
  • Your XML is ok and doesn't need editing. If setting text with android:hint works, but android:text gives an empty box, it means somewhere else that edittext is given an empty string as content with setText(). – Smokez Apr 18 '14 at 13:35
0

Remove the Visibility code from first Linear Layout.

android:visibility="gone"

replace your xml file with this

  <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@id/login_status_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical" >

<ProgressBar
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="8.0dip" />

<TextView
    android:id="@id/login_status_message_code"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginBottom="16.0dip"
    android:fontFamily="sans-serif-light"
    android:text="@string/login_progress_signing_in"
    android:textAppearance="?android:textAppearanceMedium" />

<ScrollView
    android:id="@id/login_form_code"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#ff1a1a1a" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:background="#ff0099cc"
            android:orientation="horizontal" >

            <TextView
                android:id="@id/textView5"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="10.0dip"
                android:layout_marginTop="10.0dip"
                android:gravity="center"
                android:text="Verify Code"
                android:textAppearance="?android:textAppearanceLarge"
                android:textColor="#ffffffff"
                android:textStyle="bold" />
        </LinearLayout>

        <TextView
            android:id="@id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginBottom="20.0dip"
            android:layout_marginTop="20.0dip"
            android:gravity="center"
            android:text="Enter Your Code"
            android:textAppearance="?android:textAppearanceLarge"
            android:textColor="#ffd3d3d3"
            android:textStyle="bold" />

        <EditText
            android:id="@id/phonenum_code"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="20.0dip"
            android:layout_marginRight="20.0dip"
            android:background="@drawable/box1profile"
            android:hint="@string/prompt_code"
            android:inputType="phone"
            android:maxLines="1"
            android:paddingLeft="10.0dip"
            android:singleLine="true"
            android:textColor="#ffd3d3d3" />

        <Button
            android:id="@id/sign_in_button_code"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:layout_marginTop="16.0dip"
            android:background="@drawable/codesubmit"
            android:paddingLeft="32.0dip"
            android:paddingRight="32.0dip" />
    </LinearLayout>
</ScrollView>

Amardeepvijay
  • 1,626
  • 3
  • 17
  • 47
  • @user3548321 you got your ans – Amardeepvijay Apr 18 '14 at 10:25
  • Still not working...getting error while compiling..can you please edit the xml for me and upload it in datafile host so that i can compare the two xml files or replace it?? here is the xml file http://www.datafilehost.com/d/ca0ee808 and by the way, i want to change the text inside the prompt_code(inside the strings.xml) value into number.. For example i want to change "Code" into "12345" – user3548321 Apr 18 '14 at 12:04
  • why r u using android:visibility="gone" in first linear layout section – Amardeepvijay Apr 18 '14 at 13:14
  • bro i tried removing it but nothing...can u pls edit the xml file i uploaded and give me a link?? – user3548321 Apr 18 '14 at 13:29