Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8417897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:10:06+00:00 2026-06-10T02:10:06+00:00

I created a ArrayList with an Custom Adapter to show a delete-Button next to

  • 0

I created a ArrayList with an Custom Adapter to show a delete-Button next to each item.
How can I delete one item in the List by clicking it’s corresponding delete-Button?

I read that I have to add the following Code in my getView() method:

btnDel.setTag(position);

Next I should convert the position into an int since setTag returns an Object. How do I manage this?

And then, I should create a onClickListener() Function in my getView() like this:

btnDel.setOnClick....{
arrayList.remove(index);
adapter.notifyDataSetChanged();}

How do I get the number of the current selected remove-Button or what should I put in the remove()?

I’m new to android, so please give code-examples or easy-to-understand hints 🙂

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:10:08+00:00Added an answer on June 10, 2026 at 2:10 am

    You need to create something similar to this (at least this is the way which I was going to create this functionallity) :

    public View getView(int position, View convertView, ViewGroup parent) {
        View vi = convertView;
        ViewHolder holder;
        if (convertView == null) {
            vi = inflater.inflate(R.layout.item, null);
            holder = new ViewHolder();
            holder.name = (Button) vi.findViewById(R.id.delete);
            vi.setTag(holder);
        } else
            holder = (ViewHolder) vi.getTag();
            holder.name.setText("Delete");
    
            holder.name.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
    
                arrayList.remove(position);
    
                adapter.notifyDataSetChanged();
    
            }
        });
    
        return vi;
    }
    

    Something similar to this should work for you.
    Hope it helps! : )

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I created custom adapter like this public class SettingsAdapter extends BaseAdapter{ ArrayList<String> Noptions =
I created a ListView with a custom array adapter of MyObject . One instance
I am trying to create a Custom List View Adapter by extending the ArrayList
I currently have a custom listview where each item on the list contains two
I have created a custom Base Adapter class, to populate a list view with
I've created a custom ListView with checkboxes. I wanted to delete the selected items
I currently have a custom listview with two rows of text in each item,
I have created custom listview in that have list of textview & list of
My use case is as follows -- I have a list(ArrayList) of objects, custom
I have created a custom Array Adapter to bind a custom row that contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.