whilu / AndroidTagView

A TagView library for Android. Customize your own & Drag effect.
1.71k stars 303 forks source link

How can i change the icon for remove? Could't not find it! #70

Open JaydipRadadiya opened 6 years ago

JaydipRadadiya commented 6 years ago

Hello, Is there any way to change the remove icon instead of 'X' to another drawable icons ?

whilu commented 6 years ago

Sorry, this feature is not support now. But you can use below attributes to draw your own 'X' icon:

Maybe I will support custom drawable in the feature, thanks 😄

JaydipRadadiya commented 6 years ago

Hi whilu!

Thank you for the quick response. Appreciate for the support custom drawable feature.

May i know how can i set TAG view background programmatically as a png image, so that we can resolve the issue.

whilu commented 6 years ago

Hi, JaydipRadadiya!

Try use tag_background attribute, maybe this will help you.

Thanks!

manish-poddar commented 6 years ago

Hi @whilu

Just a follow up. Have you added the support for changing the cross icon. Actually i need to add a plus icon instead of cross icon and then define some functionality. Any work around for this issue?

JaydipRadadiya commented 6 years ago

Hi @manish-poddar

I have a set + icon instead of cross for that you need to make a png (according to your UI) and set as backroung like as : tagLayout.getTagView(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_tag_add));

Thanks.

manish-poddar commented 6 years ago

Hi @JaydipRadadiya

It's not working for me. It is still showing cross sign. @whilu Any support will be appreciated.

JaydipRadadiya commented 6 years ago

Hi @manish-poddar

Have a look like this, I have used as

tagLayout.getTagView(i).setEnableCross(true);
                tagLayout.getTagView(i).setCrossColor(getResources().getColor(R.color.transparent));
                tagLayout.getTagView(i).setTagTextColor(getResources().getColor(R.color.red));
                tagLayout.getTagView(i).setBorderWidth(1);
                tagLayout.getTagView(i).setTagBorderColor(getResources().getColor(R.color.red));
                tagLayout.getTagView(i).setTagBackgroundColor(getResources().getColor(R.color.transparent));
                tagLayout.getTagView(i).setBackgroundDrawable(getResources().getDrawable(R.drawable.ic_tag_add));

Handle Click event as well like this :

tagLayout.setOnTagClickListener(new TagView.OnTagClickListener() {

            @Override
            public void onTagClick(int position, String text) {

                if (text.equalsIgnoreCase(getResources().getString(R.string.Add_Tag))) {//Default
                    startActivityForResult(new Intent(getActivity(), ViewRaceListActivity.class).putStringArrayListExtra("RACE_SELECTED_LIST", raceSelectedList), CV.INTENT100);
                } else {
                    CM.print(".... onTagClick : " + text + " position : " + position);
                }

            }

            @Override
            public void onTagLongClick(int position, String text) {

            }

            @Override
            public void onTagCrossClick(int position) {
                CM.print(".... #onTagCrossClick : " + " position : " + position + " Name : " + tagLayout.getTagText(position));

                if (tagLayout.getTagText(position).equalsIgnoreCase(getResources().getString(R.string.Add_Tag))) {//Default
                    CM.print("........Default : Add");
                    startActivityForResult(new Intent(getActivity(), ViewRaceListActivity.class), CV.INTENT100);
                } else {

                    tagLayout.removeTag(position);
                    if (raceSelectedList.size() > 0)
                        raceSelectedList.remove(position);

                    CM.print("______ raceSelectedList : Size : " + raceSelectedList.size());
                }

            }

        });