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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:43:46+00:00 2026-06-10T15:43:46+00:00

I have an application which shows a list view. I am planning to make

  • 0

I have an application which shows a list view. I am planning to make it so that when a user clicks on a listview item, a dialogue box appears showing an XML layout. But I am having just on little problem.

I have the list view up and running, and working. Here is the code in the activity class for the onclick listener.

 final ListView lv1 = (ListView) findViewById(R.id.listV_main);
        lv1.setAdapter(new ItemListBaseAdapter(this, image_details));

        lv1.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> a, View v, int position, long id) { 
                Object o = lv1.getItemAtPosition(position);
                ItemDetails obj_itemDetails = (ItemDetails)o;
                Toast.makeText(VanillaBlockList.this, "Loading details for: " + " " + obj_itemDetails.getName(), Toast.LENGTH_LONG).show();

                if(obj_itemDetails.getPrice().equals("ID - 1")){

                    // custom dialog
                    final Dialog dialog = new Dialog(Context);
                    dialog.setContentView(R.layout.va_type1);
                    dialog.setTitle("Information");

                    dialog.show();

                }

                if(obj_itemDetails.getPrice().equals("ID - 2")){
              /* Stuff here*/ }
            } 

        });
    } 

The problem is this part of the above code:

if(obj_itemDetails.getPrice().equals("ID - 1")){

                    // custom dialog
                    final Dialog dialog = new Dialog(Context);
                    dialog.setContentView(R.layout.va_type1);
                    dialog.setTitle("Stone");

                    dialog.show();

                }

The line that creates the new dialog is giving me an error. In Eclipse, the “new Dialog(Context)” has the “Context” part underlined in red, indicating an error.

Does anyone know how to fix this?

Thanks

  • 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-06-10T15:43:48+00:00Added an answer on June 10, 2026 at 3:43 pm

    Could you tell us what the error is, instead of just where it is?

    I haven’t worked much with Context or Dialog besides the very basics, but try passing in a Context object, not just the class. In the onActivityCreate method, call

    Context c = this;
    

    and then

    final Dialog dialog = new Dialog(c);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application i have a listView. each item of the list view contains
I have a xPage application which shows list of emails of the currently logged
Hi I have a page in my java/jsp based web application which shows list
I have build a web application which shows the list of customers using datalist
I have a silverlight mvvm application that loads main view with 2 user controls
I am making a list of view in my application that shows all installed
I have a windows forms application that shows data in a grid view. The
I have a list view and when item in the listview clicked, I save
I have a C# application which shows the current time in a transparent .NET
In my application, I have a 'logging' window, which shows all the logging, warnings,

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.