Pergunta

I have made a simple android dialog with 2 edittexts and a button,Its a login dialog ,I have put an image in both edit texts one is for use name and another one is for password..but second edittext doesnt display the hint that i have set ,My code is as below:

dialog.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#00000000"
    android:gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        style="@style/dialog"
        android:background="@drawable/dialoguebox"
        android:orientation="vertical" >

        <ImageView
            android:id="@+id/dialog_close"
            style="@style/close"
            android:background="@drawable/btn_close_38" />

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:paddingLeft="30dp"
            android:paddingRight="30dp" >

            <com.esp.therisemethod.uc.EspTextView
                android:id="@+id/textView1"
                style="@style/header_text"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:tag="200"
                android:text="Login"
                android:textColor="#212526" />

            <com.esp.therisemethod.uc.EspEditText
                android:id="@+id/usernm"
                style="@style/dialog_edit"
                android:background="@drawable/text_box"
                android:gravity="center"
                android:hint="Please enter your client number" />

            <com.esp.therisemethod.uc.EspEditText
                android:id="@+id/pwd"
                style="@style/dialog_edit"
                android:background="@drawable/text_box"
                android:gravity="center"
            android:hint="Enter your password"
                android:inputType="textPassword" />

            <LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="10dp"
                android:orientation="horizontal" >

                <com.esp.therisemethod.uc.EspTextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="15dp"
                    android:layout_marginTop="7dp"
                    android:tag="100"
                    android:text="Remember me"
                    android:textColor="#666666" />

                <ImageView
                    android:id="@+id/chk_login"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:background="@drawable/checkbox" />
            </LinearLayout>

            <com.esp.therisemethod.uc.EspButton
                android:id="@+id/login"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="10dp"
                android:layout_marginTop="20dp"
                android:background="@drawable/button"
                android:padding="5dp"
                android:tag="200"
                android:text="Login"
                android:textColor="#f5f0eb"
                android:textSize="17px" />
        </LinearLayout>
    </LinearLayout>

</LinearLayout>
Foi útil?

Solução

Try changing

android:inputType="textPassword"

with

android:password="true"

Outras dicas

As I remember, android wont show you hint in EditText if your InputType is "password" and gravity is "center".(but i think it was fixed in android > 2.3)

You can try changing this values. Btw, you can easily remove InputType "password" and implement it by yourself - just replace symbols with "*", but keep the original symbols.

<com.esp.therisemethod.uc.EspEditText
                android:id="@+id/usernm"
                style="@style/dialog_edit"
                android:background="@drawable/text_box"
                android:gravity="center"
                android:hint="Please enter your client number" />

From this code you doesn't use any speciel properties out of the android's. So you can change it to

<EditText
                android:id="@+id/usernm"
                style="@style/dialog_edit"
                android:background="@drawable/text_box"
                android:gravity="center"
                android:hint="Please enter your client number" />

Like this. I hope this will help you.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top