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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:36:26+00:00 2026-05-27T00:36:26+00:00

How to show the alert dialog for the empty list view when there are

  • 0

How to show the alert dialog for the empty list view when there are no listview items. Please find the below image having three text fields. I have to implement the empty list view when there are no records/unmatched records in the list.

The list view is implemented as below:

ListView empListView; 
empListView = (ListView)findViewById(R.id.list1 );

I have to show the alert dialog box for the empListView. Please help me with the samplecode/links.

  • 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-27T00:36:27+00:00Added an answer on May 27, 2026 at 12:36 am

    It all depends on how you implement the setAdapter method etc. But here is an example:

    if(cdata.getCount()==0) {
      //empty, show alertDialog
      AlertDialog.Builder builder = new AlertDialog.Builder(this);
      builder.setMessage("Search is empty")
       .setCancelable(true)
       .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
           public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
           }
       });
      AlertDialog alert = builder.create();
    } 
    else {
      //Not empty, set the adapter or do what you want. 
      empListview.setAdapter(new MyCursorAdapter( getApplicationContext(), R.layout.listview, cdata, fields, names));
    }
    

    The code above havent been tested. But should work with minor adjustments, I might have forgotten something.

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

Sidebar

Related Questions

In my program I want this alert dialog to show after 3000ms. how can
I have created a dialog that shows a multi-choice list of items that can
I'm trying to show an alert dialog with my application from a non-activity. So
Hi guys thanks in advance ... I am trying to show an alert dialog
i am using this code to show alert dialog...when i click on the ok
I would like to show an alert dialog that shows a counter(timer of time)
Good day, I am trying to show an alert dialog after a system reboot
I know how to show an alert when the user exits the browser and
I want to create a simple multiline Alert popup Alert.show(Blah\\nBlah) shows Blah\nBlah when what
<mx:CheckBox id=userlevel x=118 fontSize=12 fontWeight=bold y=127 label=Administrator/> What should be the Alert.show(userlevel.selected) returns whether

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.