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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:21:20+00:00 2026-06-04T11:21:20+00:00

I am trying to implement Delete functional to delete item from the listview. Click

  • 0

I am trying to implement Delete functional to delete item from the listview. Click On the Text “Remove Item” Item should be removed from the ListView.
I have tried but, I am getting an error in the code.
I dont have any Idea of how to correct the errors.

Here is my code:

   public View getView(final int position, View convertView, ViewGroup parent) 
    {


      final  ViewHolder holder;

        if (convertView == null) 
        {
            convertView = inflater.inflate(R.layout.selecteditemlistview, null);
            holder = new ViewHolder();

            holder.textViewSelectedText = (TextView)convertView.findViewById(R.id.selectedtext);
            holder.price=(TextView)convertView.findViewById(R.id.selectitemprice);
            holder.image=(ImageView)convertView.findViewById(R.id.selectitemimage);
            holder.qty=(EditText)convertView.findViewById(R.id.selectqty);
            holder.total=(TextView)convertView.findViewById(R.id.price);

            holder.deleteButton = (TextView) convertView.findViewById(R.id.delete);


            convertView.setTag(holder);
        }
        else 
        {
            holder = (ViewHolder) convertView.getTag();
        }
        String amount=holder.qty.getText().toString();
        final Double price1=Double.parseDouble(itemprice.get(position));
        int qut=Integer.parseInt(holder.qty.getText().toString());
        Double total=(price1*qut);
        holder.textViewSelectedText.setText(arr1.get(position));
        holder.price.setText(itemprice.get(position));
        holder.image.setImageBitmap(itemimage.get(position));
        holder.total.setText(String.valueOf(total));

        final CartItem mCartItem = (CartItem) getItem(position);


        holder.mTextView.setText(mCartItem.product_name);
        holder.deleteButton.setOnClickListener(new OnClickListener() {


            public void onClick(View v) {
                Object cartItems;
                CustomAdapter myAdapter = new CustomAdapter(CustomAdapter.this, R.layout.selecteditemlistview, cartItems);
                ListView listview = (ListView) findViewById(R.id.delete);
                listview.setAdapter(myAdapter);
                        cartItems.remove(object);
                        myAdapter.notifyDatasetChanged();


            }

        });

        return convertView;     
    }

    class ViewHolder      
    {
         public TextView deleteButton;
         public TextView mTextView;

        TextView textViewSelectedText = null;
        TextView price=null;
        ImageView image=null;      
        EditText qty=null;
        TextView total=null;
    }  
    public class CartItem {
        public int id;
        public String product_name;
    }

The Exact error is in the below code:

     holder.deleteButton.setOnClickListener(new OnClickListener() {


            public void onClick(View v) {
                Object cartItems;
                CustomAdapter myAdapter = new CustomAdapter(CustomAdapter.this, R.layout.selecteditemlistview, cartItems);
                ListView listview = (ListView) findViewById(R.id.delete);
                listview.setAdapter(myAdapter);

                Object toRemove = arrayAdapter.getItem([POSITION]);
                arrayAdapter.remove(toRemove);

            }

        });

Please Help me to solve this problem. Thank you..

This are my Logcat errors:

       05-18 12:38:04.630: I/System.out(514): Printing
       05-18 12:38:04.711: I/System.out(514): [152.00]
       05-18 12:38:04.711: I/System.out(514): arr: 1
       05-18 12:38:04.721: I/System.out(514): 152.0
       05-18 12:38:04.781: D/AndroidRuntime(514): Shutting down VM
       05-18 12:38:04.781: W/dalvikvm(514): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
       05-18 12:38:04.811: E/AndroidRuntime(514): FATAL EXCEPTION: main
       05-18 12:38:04.811: E/AndroidRuntime(514): java.lang.ClassCastException: java.lang.String
       05-18 12:38:04.811: E/AndroidRuntime(514):   at com.customer.CustomAdapter.getView(CustomAdapter.java:106)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.AbsListView.obtainView(AbsListView.java:1315)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at  android.widget.ListView.makeAndAddView(ListView.java:1727)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.ListView.fillDown(ListView.java:652)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.ListView.fillFromTop(ListView.java:709)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.ListView.layoutChildren(ListView.java:1580)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.AbsListView.onLayout(AbsListView.java:1147)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.View.layout(View.java:7035)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.RelativeLayout.onLayout(RelativeLayout.java:909)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.View.layout(View.java:7035)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.View.layout(View.java:7035)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1249)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1125)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.LinearLayout.onLayout(LinearLayout.java:1042)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.View.layout(View.java:7035)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.widget.FrameLayout.onLayout(FrameLayout.java:333)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.View.layout(View.java:7035)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.ViewRoot.performTraversals(ViewRoot.java:1045)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.view.ViewRoot.handleMessage(ViewRoot.java:1727)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.os.Handler.dispatchMessage(Handler.java:99)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.os.Looper.loop(Looper.java:123)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at android.app.ActivityThread.main(ActivityThread.java:4627)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at java.lang.reflect.Method.invokeNative(Native Method)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at java.lang.reflect.Method.invoke(Method.java:521)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
       05-18 12:38:04.811: E/AndroidRuntime(514):   at dalvik.system.NativeStart.main(Native Method)
  • 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-04T11:21:22+00:00Added an answer on June 4, 2026 at 11:21 am

    What you need is simply remove the dataset item from which you are populating your Adapter and then notify the adapter using notifyDataSetChanged()

            holder.deleteButton.setOnClickListener(new OnClickListener() {
                public void onClick(View v) {
                     yourdataset.remove(position);
                     notifyDataSetChanged();
                }
            });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement ListView with Delete functionality to delete item from the
I have been trying to implement the delete BST function but I don't know
I've been trying to implement a delete function for a Binary Search Tree but
Im trying to implement an Observer/Observable pattern on an EC2 instance. I have been
i'm trying to implement a massive delete action to a list of items, where
I am trying to implement SMS kind of swipe and delete functionality. In case
I'm trying to implement QAbstractItemModel for QTreeView. I have problem with inserting rows. I
I'm trying to implement a simple ActionLink that will delete records using ASP.NET MVC.
I have been trying to implement DoJo Enhanced Grid with Json and I have
I have been trying to implement Win32's MessageBox using GTK. The app uses SDL/OpenGL,

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.