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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:02:11+00:00 2026-05-30T10:02:11+00:00

in my app when i click a button showing a dialog box with listview.

  • 0

in my app when i click a button showing a dialog box with listview. The list of items are been shown from an array list. Following is the bit of my code

private void album_list_box() 
    {
        Dialog dialog = new Dialog(Nearme_Image_DetailView.this);
        AlertDialog.Builder builder = new AlertDialog.Builder(Nearme_Image_DetailView.this);
        builder.setTitle("Select the Album Name");

        ListView modeList = new ListView(this);
        for(int i =0; i< Get_album_name_array.size(); i++)
        {
            stringArray = Get_album_name_array.get(i);
            HashMap<String, Object> map = new HashMap<String, Object>(); 
            map.put("fname", stringArray);
            listItem.add(map);
        }
        SimpleAdapter listItemAdapter = new SimpleAdapter(this,listItem,android.R.layout.simple_list_item_1,new String[] {"fname"}, new int[] {android.R.id.text1});   
        modeList.setAdapter(listItemAdapter);

        builder.setView(modeList);
        dialog = builder.create();
        dialog.show();
    }

Here i am a getting the alertbox and list of items, when i click i am able to get the position.

But when the list is clicked i want to close the dialog and i want to start an async Task, how to do this……

  • 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-30T10:02:13+00:00Added an answer on May 30, 2026 at 10:02 am

    Declare the dialog as class member, set up the click listener for the ListView

    lv.setOnItemClickListener(new OnItemClickListener() {    
        public void onItemClick(AdapterView<?> parent,View view,int position,long id) {
            //your code
            mdialog.cancel(); // close the dialog box
            asynctask = new ASyncTask().execute(); // start a aynctask of your choice
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my Swing app, users can click a button to open a dialog panel
In my app I have a listview with news items showing only a summary,
in my app when i click a button i am getting some data from
I'm in the midst of writing a slide show app (click a button, and
Hello StackOverflow'ers, I have a (flex) app that, on the click of a button,
I need a function that a user can just click a flash app button
I have the following UI for an iPad app: When I click on the
in my app i am trying to download some video in button click. i
i get the following when i click update after unchecking the full time box.
My Info button is showing up when I run my app but it doesn't

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.