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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:25:13+00:00 2026-05-20T20:25:13+00:00

I show dialog of checkboxes (list retrieved from DB) to allow user select, which

  • 0

I show dialog of checkboxes (list retrieved from DB) to allow user select, which rows remove. Because android dialog caching, I need to refresh count and names of checkboxes.
In my onCreateDialog:

dialog =  new AlertDialog.Builder( this )
       .setTitle( "Remove Items" )
       .setMultiChoiceItems( items, _selections, new OnMultiChoiceClickListener(){public void onClick (DialogInterface dialog, int which, boolean isChecked){}} )
       .setPositiveButton("Smazat", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) { 
            dialog.dismiss(); 
            deleteRow(_selections);
            } })
        .setNegativeButton("Storno", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) { 
            dialog.dismiss(); 
            } })
       .create();

How refresh values (items,_selections) in onPrepareDialog?
I tried invalidate views, hoping that force android to load items againg(dont work neither), but I think its bad choice as well as removing dialog and recreating.

protected void onPrepareDialog(final int id, final Dialog dialog) {
          switch (id) {
          case REMOVE_DIALOG_ID:

              ListView lv = ((AlertDialog) dialog).getListView();
                lv.invalidateViews();

          break;
          }

Thanks for any ideas!

  • 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-20T20:25:14+00:00Added an answer on May 20, 2026 at 8:25 pm

    When you create a list of items using AlertDialog.Builder, it internally takes that and creates a ListAdapater that is dependent on the type of data you passed. Since “items” in your example doesn’t look like a resource ID, I’m assuming it’s either a CharSequence[] or a Cursor. If you provide more information about what “items” is, I can provide a more concrete example.

    • For CharSequence[] (like String[]) data, Builder creates an ArrayAdapter instance.
    • For Cursor data, Builder creates a CursorAdapter

    You will need to obtain a reference to this ListAdapter using getListView().getAdapter() on the AlertDialog instance.

    For a Cursor, you can get away with calling notifyDataSetChanged() after you have called requery() to update the data set.

    Since you can’t “update” an array with new data (changing the pointer to a new instance is not the same thing…the instance that the adapter is pointing to stays unchanged), this case is a little more work. You will need to call the add(), clear(), etc. methods of the adapter to remove invalid items and add the updates ones. With the adapters data set fully updated, you may now call notifyDataSetChanged().

    Hope that Helps!

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

Sidebar

Related Questions

I want to show a dialog that will allow the user to select a
I want to show a dialog box in my Android app to let the
I have a function to show Dialog. public Dialog sendSMS(){ Dialog dialog = new
I want to show some dialog (absolute positioned div), and I want to show
I want to show a Dialog with an EditText . I envision it having
I'd like to show a Dialog that occupies as much screen space as possible.
I am trying to show a Dialog box on onPostExecute method of an AsyncTask
I am using this code to show a dialog box that will confirm for
I want my Application to show Custom Dialog When an Uncatch Exception occur. For
I'm using a context-menu item click to show a dialog (using JQuery/Bootstrap) that lets

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.