mabbas007 / TagsEditText

Android EditText for view tags or chips
Apache License 2.0
694 stars 124 forks source link

How to insert multiple tags #45

Open ashishparmar opened 6 years ago

ashishparmar commented 6 years ago

Here i have scenario like i want to add tag after every 8 digit , When i complete the 8 digit than i want to add tag with a string like "NCT-12345678". I have implement logic for count 8 digit while user insert. but i could not add that as Tag. My logic for insert tags like below

`
try {

              if (digit == 8) {

                        String getCurrentString = charSequence.toString();

                        if (getCurrentString.length() > 0) {

                            String getCurrentText = getCurrentString.substring(getCurrentString.length() - 8);

                            List<String> allTags = tag_value.getTags();

                            allTags.add("NCT-" + getCurrentText.toString());

                            final String[] charSequenceItems = allTags.toArray(new String[allTags.size()]);

                            for (int j = 0; j < charSequenceItems.length; j++) {

                                Log.e("NCT", charSequenceItems[j].toString());

                            }
                            Runnable runnable = new Runnable() {
                                public void run() {
                                    tag_value.setTags(charSequenceItems);
                                }
                            };
                            new Handler().postDelayed(runnable,1000);

                        }
                        digit = 0;
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }`