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 8670811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:47:44+00:00 2026-06-12T18:47:44+00:00

In the list Items, there is a button delete and textview.. on click of

  • 0

enter image description here

In the list Items, there is a button “delete” and textview.. on click of delete button in list item I am deleting that particular list item.. but My question is:that delete button is invisible at the start and when user click on “edit” button shown below at the top of the screen, I want to make all the buttons from invisible to visible.. But I am not getting how to implement that..

ListViewAdapater.java :

public class ListViewAdapter extends BaseAdapter {

    public ArrayList<String> list;
    Context context;
    private LayoutInflater mInflater;

    int count = 0;
    static int list_size;

    public ListViewAdapter(Context context, ArrayList<String> list) {
        super();
        this.context = context;
        this.list = list;
        mInflater = LayoutInflater.from(context);
        list_size = list.size();
    }

    public int getCount() {
        if (list == null) {
            return 0;
        } else {
            return list_size;
        }
    }

    @Override
    public Object getItem(int position) {
        Log.i("Calling getItem()", "getItem()");
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        Log.i("Calling getItemId()", "getItemId()");
        return position;
    }

    static class ViewHolder {
        TextView notes_text;

        static Button delete;
    }

    //  @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Log.i("ListViewAdapter is calling...", "calling...");
        ViewHolder holder;
        Log.i("View to be converted", "" + convertView);
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.simplerow, null);
            Log.i("View to be converted", "" + convertView);
            holder = new ViewHolder();
            holder.notes_text = (TextView) convertView.findViewById(R.id.rowTextView);

            holder.delete = (Button) convertView.findViewById(R.id.btn_minus);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.notes_text.setText((String) list.get(position));

        holder.delete.setTag((Integer) position);

        holder.delete.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View view) {
                Integer myIntegerObject = new Integer((Integer) view.getTag());
                Log.i("Integer postioton", "" + myIntegerObject.intValue());

                list.remove(list.indexOf(list.get(myIntegerObject.intValue())));

                list_size = list.size();

                notifyDataSetChanged();
            }
        });

        return convertView;
    }
}
  • 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-12T18:47:45+00:00Added an answer on June 12, 2026 at 6:47 pm

    Keep a boolean flag to indicate edit mode. In ListAdapter‘s getView() set Button visibility to VISIBLE or GONE depending on your boolean flag.

    Now, to toggle all button visibility you have so change boolean flag, and call notifyDataSetChanged() on adapter. This will re-draw all visible List Items.

    add variable in adapter class:

    boolean editmode = false;
    

    In getView() :

    holder.delete.setVisibility( (editmode ? View.VISIBLE : View.GONE ) );
    

    finally add a method to your adapter class:

    public void setEditMode(boolean value){
      editmode = value;
      this.notifyDataSetChanged();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list which is dynamically built, but there are empty list items
Is there a list of items on the web that you should not use
Is there any way to select items in a list that aren't contained in
In my application, the user click a delete button to delete items from a
I'm trying to delete ListView items that are checked. It works if there is
I have a unordered list <ul id=images > . There are 3 list items
In Python, is there a way to check for duplicate items in a list,
Is there a way to get all versions of list item(s) using a CAML
Is there a way to get the previous item in a list , based
In my application there is a ListFragment where each item from the list 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.