Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void OnClick_click2(final Button btnadd)
- {
- final Button btn = (Button) btnadd;
- if(btn.getId()==R.id.btnadd){
- if(validEdittext(complain_date_txtbx))
- {
- if(validEdittext(complain_time_txtbx))
- {
- if(validEdittext(job_performed_txtbx))
- {
- if(validEdittext(next_due_on_txtbx))
- {
- // show alert here
- showAlertbox(String strmessage);
- }
- else{
- //show toast next_due_on_txtbx is empty
- }
- }
- else{
- //show toast here job_performed_txtbx is empty
- }
- }
- else{
- //show toast here complain_time_txtbx is empty
- }
- }
- else{
- //show toast here date_txtbx is empty
- }
- }
- }
- //Create EditText Validation method here
- public boolean validEdittext(EditText edttext){
- String strtxt=edttext.getText().toString();
- return strtxt != null && !strtxt.isEmpty() && !strtxt.trim().isEmpty();
- }
- public void showAlertbox(String strmessage){
- AlertDialog.Builder alert = new AlertDialog.Builder(
- non_ticket_task.this);
- alert.setPositiveButton("Save",
- new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface arg0, int arg1) {
- // Perform action on click
- EditText complain_date_txtbx = (EditText) findViewById(R.id.complain_date_txtbx);
- EditText complain_time_txtbx = (EditText) findViewById(R.id.complain_time_txtbx);
- EditText job_performed_txtbx = (EditText) findViewById(R.id.job_performed_txtbx);
- EditText next_due_on_txtbx = (EditText) findViewById(R.id.next_due_on_txtbx);
- String data = complain_date_txtbx.getText().toString()
- .trim()
- + Spliter
- + complain_time_txtbx.getText().toString().trim()
- + Spliter
- + job_performed_txtbx.getText().toString().trim()
- + Spliter
- + next_due_on_txtbx.getText().toString().trim();
- SaveRecord(data);
- Toast.makeText(getBaseContext(),
- "Your Task saved Successfully!",
- Toast.LENGTH_LONG).show();
- }
- });
- alert.setNegativeButton("Cancel",
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog,
- int whichButton) {
- dialog.cancel();
- }
- });
- alert.show();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement