I have an EditText
with some information in it. When there is no information,
I'm displaying a caption using setHint()
.
final EditText info = new EditText(activity);
if (data.getinfo() != null && !data.getAddress().trim().equals("")) {
info.setText(data.getinfo());
} else {
info.setHint(R.string.info);
}
I want to show that caption even if the EditText
has info, the info should be below the caption.
I tried using setText()
. But that didn't work either.
if (condition) {
info.setText(R.string.info);
info.setText(data.getinfo());
} else {
info.setHint(R.string.info);
}
Within a
RelativeLayout
, use aTextView
as an overlayView
on top of yourEditText
. Use appropriate colors, size for the font to achieve the effect you are looking for.Here is a hint
This is just a starting point, you can adjust the height of your
EditText
, position yourTextView
, change itsgravity
, etc., to achieve what you are looking for.You can directly do it through xml tag which you've added in your UI layout.