2

I'm trying to remove and refresh from Listview using CustomAdapter using the coding below

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    SubjectData subjectData = arrayList.get(position);


    if (convertView == null) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        convertView = layoutInflater.inflate(R.layout.notifications_list, null);

        listView = convertView.findViewById(R.id.notificationlist);


        convertView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                String item = subjectData.notice_id.toString();
                arrayList.remove(item);
                listView.refreshDrawableState();

            }
        });
Adam
  • 13
  • 3

2 Answers2

0

You can use adapter.notifyDataChanged()

aflopezbec
  • 91
  • 1
  • 6
0

Use arrayAdapter.notifyDataSetChanged(); after remove your item.

You can follow this answser

Atik Faysal
  • 158
  • 1
  • 13