Reputation: 591
actually humm...let me try to explain... I was following the tutorial for android app starters and with this code the EditText part the there will be a default message which was set in the string but the default message is grey and when we use the phone and click on the EditText part the grey message will be gone....I tried doing this again but what I get is that the default message is black and when I click on the EditText on the phone the message will stay instead of gone which means I have to delete the message manually to enter what is wanted. Anyone can give me a hand with it?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<EditText android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/edit_message" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/button_send"
android:onClick="sendMessage" />
</LinearLayout>
The above is something I want and the below is what I have,
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
/*have a few more EditText, Buttons and TextView here but don't think it's relevant so didn't paste*/
<EditText
android:id="@+id/edit_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/editText1"
android:layout_alignParentBottom="true"
android:ems="10"
android:inputType="numberDecimal"
android:text="@string/edit_percentage" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/edit_percentage"
android:layout_alignRight="@+id/editText1"
android:text="@string/button3" />
</RelativeLayout>
I did thought if it's because of the relativelayout and linearlayout but didn't seem to be the problem.
Upvotes: 0
Views: 524
Reputation: 2309
Use android:text
attribute.
<EditText android:id="@+id/edit_message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/edit_message" />
Upvotes: 0
Reputation: 44571
It sounds like you want hint
. Add this line
android:hint="@string/edit_percentage"
instead of
android:text="@string/edit_percentage"
Upvotes: 1