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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:33:25+00:00 2026-05-21T17:33:25+00:00

Hi I have a alertdialog that is create when you click on an item

  • 0

Hi I have a alertdialog that is create when you click on an item in a listview, Im trying to get the name of the file,description, author etc.. from my activity and display it in my alertdialog but .setText will not work, can someone please help. Thank you, here is my code: http://pastebin.com/FzWSPp5e

  • 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-21T17:33:26+00:00Added an answer on May 21, 2026 at 5:33 pm

    this is not at all how you properly use dialogs in Android. you need to define your dialogs in an override of onCreateDialog, as described in the documentation:

    http://developer.android.com/guide/topics/ui/dialogs.html
    

    following this guide, you should be able to fix your problem. here’s an example i just copied and pasted from a random app:

    @Override
    protected Dialog onCreateDialog(int id, Bundle b) {
        LayoutInflater inflater = (LayoutInflater) this.getSystemService(this.LAYOUT_INFLATER_SERVICE);
        AlertDialog.Builder builder = null;
        switch(id) {
            case DIALOG_BLOCK_SIZE:
            {
                Dialog dialog = new Dialog(this);
                final View dialogLayout = inflater.inflate(R.layout.dialog_block_size, null);
                builder = new AlertDialog.Builder(this);
                builder.setView(dialogLayout);
                builder.setTitle("Set Block Size");
    
                final EditText blockIn = (EditText)dialogLayout.findViewById(R.id.block_size_in);
                blockIn.setText(new Integer(pref.getInt("block_size", 6)).toString());
    
                builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            SharedPreferences.Editor editor = pref.edit();
                            editor.putInt("block_size", new Integer(blockIn.getText().toString()));
                            editor.commit();
                            ////////TODO///////////
                            //notify MinutemaidService that we have changed the block_size
                            dialog.dismiss();
                        }
                    });
                builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    });
                dialog = builder.create();
                return dialog;
            }
            default:
            {
                return null;
            }
        }
        return dialog;
    }
    

    with the above code, you can call showDialog(DIALOG_BLOCK_SIZE) to show the dialog. also note that dialogs are created once and shown over and over again. to force rebuilding a dialog, call removeDialog(int) before calling showDialog(int). overriding onPrepareDialog() is the best method, but using removeDialog works and it’s easier.

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

Sidebar

Related Questions

I have a DialogFragment that creates a listview dialog and on a list item
I have a table that I am trying to dynamically delete rows from. Each
I have a Login dialog that can create an alert dialog when the user
I have button that a user selects and I pop up a AlertDialog to
I have a TextViewer Activity , that has a button, and when I click
I'm trying to create an application that can use the android as a fax
I'm trying to create a DialogFragment using a custom view in an AlertDialog .
I have a popup I want to create that will have 3 choices. (Block,
i want to have in my application an alertdialog, that has its message updated
I have already asked this, but didn't get an solution that works and I

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.