Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. private void OpenCategroyDialogBox() {
  2.  
  3. LayoutInflater layoutInflater = LayoutInflater.from(this);
  4. View promptView = layoutInflater.inflate(R.layout.addnewcategory, null);
  5. final AlertDialog.Builder alert = new AlertDialog.Builder(this);
  6. alert.setTitle("Dodaj link do serialu");
  7. alert.setView(promptView);
  8.  
  9. final EditText input = (EditText) promptView
  10. .findViewById(R.id.etCategory);
  11. final EditText input2 = (EditText) promptView
  12. .findViewById(R.id.etCategory2);
  13.  
  14. input.requestFocus();
  15. input.setHint("Podaj link");
  16. input.setTextColor(Color.BLACK);
  17.  
  18. input2.setHint("Podaj nazwę");
  19. input2.setTextColor(Color.BLACK);
  20.  
  21.  
  22. alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  23. public void onClick(DialogInterface dialog, int whichButton) {
  24. String newCategoryName = input.getText().toString();
  25. String newCategoryName2 = input2.getText().toString();
  26.  
  27. // Do something with value!
  28.  
  29. if (newCategoryName.equals("") || newCategoryName2.equals("") ) {
  30. //input.setError("Name Required");
  31. OpenCategroyDialogBox();
  32. } else {
  33. ZarzadcaBazy zb = new ZarzadcaBazy(getApplicationContext());
  34. zb.dodajSerial(newCategoryName2,newCategoryName,"");
  35. pobierzDaneZbazy(zb);
  36. Toast.makeText(getApplicationContext(),
  37. "Dodano", Toast.LENGTH_SHORT).show();
  38.  
  39.  
  40. }
  41. }
  42.  
  43.  
  44.  
  45. });
  46.  
  47. alert.setNegativeButton("ANULUJ",
  48. new DialogInterface.OnClickListener() {
  49. public void onClick(DialogInterface dialog, int whichButton) {
  50. // Canceled.
  51.  
  52. // Toast.makeText(getApplicationContext(),
  53. // "Ok Clicked", Toast.LENGTH_SHORT).show();
  54.  
  55.  
  56. }
  57. });
  58.  
  59. // create an alert dialog
  60. AlertDialog alert1 = alert.create();
  61.  
  62. alert1.show();
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement