|
1 | | -"# SelectionDialog" |
| 1 | +# Welcome to SelectionDialog! |
| 2 | + |
| 3 | +Hello World. |
| 4 | +Enable Selections features. Now easy with SelectionDialog android library. You can now enable Single selection and Multiple selection features in your app easily. |
| 5 | + |
| 6 | + |
| 7 | +# Implementation |
| 8 | +**Step: 1** |
| 9 | + Add the JitPack repository to your build file. |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | + allprojects { |
| 14 | + repositories { |
| 15 | + maven { url 'https://jitpack.io' } |
| 16 | + } |
| 17 | + } |
| 18 | + **Step: 2** |
| 19 | + Add the SelectionDialog dependency to your build.gradle file. |
| 20 | + |
| 21 | +```css |
| 22 | +dependencies { |
| 23 | + implementation 'com.github.AndroidLibrariesYoutube:SelectionDialog:0.1.9' |
| 24 | + } |
| 25 | +``` |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +## How do I use Single Selection Dialog? |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | + |
| 35 | +Using SelectionDialog is pretty simple. |
| 36 | + |
| 37 | +**Step 1** |
| 38 | +Create class of SingleSelectionDialog for using the Single Selection. |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | + // First parameter you need to pass is this means you need to implement a SingleSelectionListener in your activity then activity context and last is TAG. |
| 43 | + |
| 44 | + |
| 45 | + SingleSelectionDialog singleSelectionDialog = new SingleSelectionDialog(this, context, "TAG"); |
| 46 | + |
| 47 | + //Then you need to the ArrayList which you want to show. ArrayList must be of String type. |
| 48 | + singleSelectionDialog.setContent(stringArrayList); |
| 49 | + |
| 50 | +**Step 2** |
| 51 | +Add extra features to your dialog. |
| 52 | + |
| 53 | + |
| 54 | + singleSelectionDialog.setColor(getResources().getColor(R.color.colorPrimaryDark)); |
| 55 | + singleSelectionDialog.setTitle("Select Number"); |
| 56 | + singleSelectionDialog.setSelectedField(currentField); |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | +**Step 3** |
| 61 | +Call show(); method for showing the dialog. |
| 62 | + |
| 63 | + singleSelectionDialog.show(); |
| 64 | +**Step 4** |
| 65 | +Inherit SingleSelectionListener listener in your activity like this. |
| 66 | + |
| 67 | + public class MainActivity extends AppCompatActivity implements SingleSelectionListener |
| 68 | +**Step 5** |
| 69 | +Get value, positions, TAG and error from dialog. |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + @Override |
| 74 | + public void onDialogItemSelected(String s, int position, String tag) { |
| 75 | + |
| 76 | + } |
| 77 | + |
| 78 | + @Override |
| 79 | + public void onDialogError(String error, String tag) { |
| 80 | + |
| 81 | + } |
| 82 | + |
| 83 | + |
| 84 | +## How do I use Multi Selection Dialog? |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +Using MultiSelection is also not that tough. |
| 90 | + |
| 91 | +**Step 1** |
| 92 | +Create class of SingleSelectionDialog for using the Single Selection. |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + // First parameter you need to pass is this means you need to implement a MultiSelectionListenerin your activity then activity context and last is TAG. |
| 97 | + |
| 98 | + |
| 99 | + MultiSelectionDialog multiSelectionDialog = new MultiSelectionDialog(this, context, "TAG"); |
| 100 | + |
| 101 | + //Then you need to the ArrayList which you want to show. ArrayList must be of String type. |
| 102 | + multiSelectionDialog.setContent(stringArrayList); |
| 103 | + |
| 104 | + |
| 105 | +**Step 2** |
| 106 | +Add extra features to your dialog. |
| 107 | + |
| 108 | + |
| 109 | + multiSelectionDialog.setColor(getResources().getColor(R.color.colorPrimaryDark)); |
| 110 | + multiSelectionDialog.setTitle("Select Number"); |
| 111 | + multiSelectionDialog.setSelectedFields(currentField); |
| 112 | + |
| 113 | +**Step 3** |
| 114 | +Call show(); method for showing the dialog. |
| 115 | + |
| 116 | + multiSelectionDialog.show(); |
| 117 | + |
| 118 | +**Step 4** |
| 119 | +Inherit MultiSelectionListener listener in your activity like this. |
| 120 | + |
| 121 | + public class MainActivity extends AppCompatActivity implements MultiSelectionListener |
| 122 | +**Step 5** |
| 123 | +Get values, selected item list, TAG and error from dialog. |
| 124 | + |
| 125 | + |
| 126 | + |
| 127 | + |
| 128 | + @Override |
| 129 | + public void onMultiDialogItemsSelected(String s, String tag, ArrayList<String> selectedItemList) { |
| 130 | + |
| 131 | + } |
| 132 | + |
| 133 | + @Override |
| 134 | + public void onMultiDialogError(String error, String tag) { |
| 135 | + |
| 136 | + } |
| 137 | + |
| 138 | + |
| 139 | +## Author |
| 140 | +[Dheeraj Rijhwani (Android Developer)](https://www.youtube.com/channel/UCEhHMXJs1V4mXGfJ4pSWaoA) |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
0 commit comments