Advertisement
Guest User

Untitled

a guest
Dec 19th, 2012
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.13 KB | None | 0 0
  1. public void OnClick_click2(final Button btnadd)
  2. {
  3. final Button btn = (Button) btnadd;
  4. if(btn.getId()==R.id.btnadd){
  5.  
  6. if(validEdittext(complain_date_txtbx))
  7.  
  8. {
  9.  
  10. if(validEdittext(complain_time_txtbx))
  11. {
  12. if(validEdittext(job_performed_txtbx))
  13. {
  14. if(validEdittext(next_due_on_txtbx))
  15. {
  16. // show alert here
  17. showAlertbox(String strmessage);
  18. }
  19.  
  20. else{
  21. //show toast next_due_on_txtbx is empty
  22. }
  23.  
  24. }
  25.  
  26. else{
  27. //show toast here job_performed_txtbx is empty
  28. }
  29.  
  30. }
  31.  
  32. else{
  33. //show toast here complain_time_txtbx is empty
  34. }
  35.  
  36. }
  37.  
  38. else{
  39. //show toast here date_txtbx is empty
  40. }
  41.  
  42. }
  43. }
  44.  
  45. //Create EditText Validation method here
  46.  
  47. public boolean validEdittext(EditText edttext){
  48.  
  49. String strtxt=edttext.getText().toString();
  50.  
  51. return strtxt != null && !strtxt.isEmpty() && !strtxt.trim().isEmpty();
  52. }
  53.  
  54.  
  55. public void showAlertbox(String strmessage){
  56. AlertDialog.Builder alert = new AlertDialog.Builder(
  57. non_ticket_task.this);
  58.  
  59. alert.setPositiveButton("Save",
  60. new DialogInterface.OnClickListener() {
  61.  
  62. @Override
  63. public void onClick(DialogInterface arg0, int arg1) {
  64. // Perform action on click
  65. EditText complain_date_txtbx = (EditText) findViewById(R.id.complain_date_txtbx);
  66. EditText complain_time_txtbx = (EditText) findViewById(R.id.complain_time_txtbx);
  67. EditText job_performed_txtbx = (EditText) findViewById(R.id.job_performed_txtbx);
  68. EditText next_due_on_txtbx = (EditText) findViewById(R.id.next_due_on_txtbx);
  69.  
  70. String data = complain_date_txtbx.getText().toString()
  71. .trim()
  72. + Spliter
  73. + complain_time_txtbx.getText().toString().trim()
  74. + Spliter
  75. + job_performed_txtbx.getText().toString().trim()
  76. + Spliter
  77. + next_due_on_txtbx.getText().toString().trim();
  78.  
  79. SaveRecord(data);
  80.  
  81. Toast.makeText(getBaseContext(),
  82. "Your Task saved Successfully!",
  83. Toast.LENGTH_LONG).show();
  84. }
  85. });
  86.  
  87. alert.setNegativeButton("Cancel",
  88. new DialogInterface.OnClickListener() {
  89. public void onClick(DialogInterface dialog,
  90. int whichButton) {
  91. dialog.cancel();
  92. }
  93. });
  94.  
  95. alert.show();
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement