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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:10:17+00:00 2026-05-22T22:10:17+00:00

So I have searched through a few question here regarding the AlertDialog, and I’m

  • 0

So I have searched through a few question here regarding the AlertDialog, and I’m not completely sure what I’m doing, so I am having a hard time relating those questions to my own example. (I’m still new to this whole android programming so please bear with me.)

I have defined this under the public class _ Activity implements OnCLickListener …

    public AlertDialog myAlertDialog;

And then I have this under the onClick

    public void onClick(View src) {

    switch(src.getId()){
    case R.id.buttonOk:
        if (score==0){
            AlertDialog.Builder myAlertDialog = new AlertDialog.Builder(this);
            myAlertDialog.setTitle("Title");
            myAlertDialog.setMessage("Message");
            myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    return;
                } }); 
            myAlertDialog.show();
        }

This line and the line below it have errors:

myAlertDialog.setButton("OK", new DialogInterface.OnClickListener() {

Errors:

1st: Multiple markers at this line
– DialogInterface cannot be resolved to a type
– The method setButton(String, new OnClickListener(){}) is undefined for the type

2nd: DialogInterface cannot be resolved to a type

Can anyone tell me what I am doing wrong please?

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-05-22T22:10:18+00:00Added an answer on May 22, 2026 at 10:10 pm

    I’m pretty sure you just aren’t importing the DialogInterface. Try adding this statement to the beginning of your code.

    import android.content.DialogInterface;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have searched through many times but have not seen this before. Probably really
This is quite a noobish question, I have searched for a few hours now
I've searched around for this question, there's quite a few of them here on
I have searched through internet & found that there are no any direct method
I have searched through the net and still have no clue how to do
Im trying to translate an object without using glTranslate(). I have searched through web
I have searched through Google, SO and Android developers but I need some further
new to IOS OpenGL programming. I have worked through a few tutorials that talk
I've been back and forth through a few posts here, and also checked out
Firstly, I have searched for related answers, there is a few - but couldn'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.