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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:55:51+00:00 2026-05-16T15:55:51+00:00

I have a table that I am trying to dynamically delete rows from. Each

  • 0

I have a table that I am trying to dynamically delete rows from. Each row has a delete button, which opens a confirmation dialog. I would like to remove this table row when confirmation gives a positive result.

I got this working, rather sloppily, and was wondering if there was a simpler way to accomplish my goal. To clarify things in the code sample, my table needs to be created dynamically, so I gave the delete buttons an id of the row id + 2000. I also destroy and recreate the dialog in each onPrepareDialog(). Is there a cleaner way to do this, specifically without destroying and recreating the dialog each time it is opened? Thank you very much!

Some code from my main Activity class:

    private OnClickListener deleteRowListener = new OnClickListener() {

                public void onClick(View v) {
                    Bundle args = new Bundle();
                            args.putInt(DELETE_ID_KEY, v.getId());
                    showDialog(DIALOG_DELETE,args);
                }
        };



        @Override
        protected void onPrepareDialog(int id, Dialog dialog, Bundle args) {

            switch (id) {
                case DIALOG_DELETE : {
                    removeDialog(id);
                    dialog = createDeleteDialog(args);
                }
            }
        }

        @Override
        protected Dialog onCreateDialog(int id, Bundle args) {
            switch (id) {
                case DIALOG_DELETE : {
                    return createDeleteDialog(args);
                }
            }
            return null;
        }

private Dialog createDeleteDialog(Bundle args) {
        final int toDeleteId = args.getInt(DELETE_ID_KEY) - 2000;  //FSP!!
        return new AlertDialog.Builder(this)
        .setPositiveButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
             TableRow row = rowsMap.get(toDeleteId);  
                 myTable.removeView(row);
            }
        })
        .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                dialog.cancel();
            }
        })
        .create();
    }
  • 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-05-16T15:55:51+00:00Added an answer on May 16, 2026 at 3:55 pm

    this may be helpful (note- that makes use of an API that isn’t available in 1.5 – You could do a fairly simple workaround if you need cupcake compatibility, though)

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

Sidebar

Related Questions

I have simple table that has about 80 rows, which I populate dynamically using
I'm trying to have a simple html table, that highlights a row as a
I have a page that is creating dynamically created rows in a table with
I am trying to create a CSV file from a dynamically generated table.I have
I'm trying to normalize a mysql database.... I currently have a table that contains
I have a data.frame and I'm trying to create a frequency table that shows
I have a heap based table in MySQL that I am trying to update
I have a MySQL table containing a listing of events that I am trying
I have several tables that I am selecting data from. I am trying to
I have table that I insert data with following query (from c# code): INSERT

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.