Sunday, September 16, 2012

Android EditText Hint ( Default Text )


android edittext hint
Placing a label on any side of EditText is not practical every time , so the best way to let users know what to type in the field ? is by setting a default text in the EditText.

In Android if we set the default text using EditText.setText(""); function , then we should write some more code for best function.

So the solution is you can simply set the hint in the XML file. just check the code below.

 <EditText  
     android:id="@+id/editTextTitle"  
     android:layout_width="match_parent"  
     android:layout_height="wrap_content"   
     android:hint="@string/defTitle">  
     </EditText>  

In the above code hint property sets the text.

 android:hint="@string/defTitle"  

0 Responses to “Android EditText Hint ( Default Text )”

Post a Comment