Notify user when Spinner and EditText is Empty
I want to notify the user if the spinner field is not
selected. How can I perform such a notification without using a Toast?
Try these line of code in your project which are give below:
Write these of code on onCreate ( ) Method
Here return statement will stop the flow of your program
Spinner
Spinner remarks = (Spinner) findViewById(R.id.sp_remarks2);
if (remarksvalue.equalsIgnoreCase("Select")) { TextView errorText = (TextView)remarks.getSelectedView(); errorText.setError(" Please Select Remarks"); errorText.setTextColor(Color.RED);//just to highlight that this is an error errorText.setText("Please Select Remarks"); return;}
EditText
EditText et_newreading = (EditText)findViewById(R.id.ed_light);
if (newreadingvl.isEmpty()) { et_newreading.setError("Please Enter Meter Reading"); return;}
Comments
Post a Comment