There is this adapter
public class ListViewClearAdapter extends BaseAdapter { private Context context; ArrayList<itemSelect> objects; ListViewClearAdapter adapter = this; public ListViewClearAdapter(Context context, ArrayList<itemSelect> itemSelects) { this.context = context; this.objects = itemSelects; } @Override public int getCount() { return objects.size(); } @Override public Object getItem(int position) { return objects.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(final int position, View convertView, ViewGroup parent) { View customView = convertView; final itemSelect itemSelects = getItemList(position); if (convertView == null) { LayoutInflater li = LayoutInflater.from(context); customView = li.inflate(R.layout.list_item_clear, null); customView.findViewById(R.id.ripple).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { objects.remove(position); adapter.notifyDataSetChanged(); } }); customView.findViewById(R.id.ripple2).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); TextView textView = (TextView) customView.findViewById(R.id.textView); textView.setText(itemSelects.name); } return customView; } itemSelect getItemList(int position) { return ((itemSelect) getItem(position)); } } When I click on the button, I delete from the dynamic array of objects and update the adapter.
customView.findViewById(R.id.ripple).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { objects.remove(position); adapter.notifyDataSetChanged(); } }); But instead of removing the desired item, it deletes the items sequentially from the bottom.