Prithniraj Nicyone
Prithniraj Nicyone

Reputation: 5111

SetError with setFocusable(false) in android

I am having an edittext and an icon. Clicking on this icon I show DateTime Picker. I have set setFocusable(false); and using setError on this edittext. But when any error occurs only icon is getting shown. Text is not getting shown at all. I have tried _input.setFocusableInTouchMode(true); also but it gives users to enter any text in this edittext which I do not want as I have created this edittext for date time only.

So, how can I show the error message then, can someone please help me.

Thanks a lot in advanced.

Upvotes: 2

Views: 958

Answers (3)

Ajay Chauhan
Ajay Chauhan

Reputation: 1551

Add following lines to your code:

et.setFocusable(true);
et.setFocusableInTouchMode(true);
et.requestFocus();

Upvotes: 2

AiVision
AiVision

Reputation: 4233

You use like this if you want to set Error on your edittext with icon

ed_emailId.setError("your Error message",R.drawable.ic_profile);

and if you want to set only error and icon will default then use like

ed_emailId.setError("your Error message");

i hope this will help you

Upvotes: 0

Fruw
Fruw

Reputation: 26

Why do you use an edittext, if you do not want the user to input text? you can use a textView and textView.setText("your time") instead.

Upvotes: 1

Related Questions