M D
M D

Reputation: 47807

AlertDialog.Builder cannot be resolved to a type error

I receive the error on the line below:

AlertDialog.Builder  alrtDialog = new AlertDialog.Builder(this);

The Error show is :

AlertDialog.Builder cannot be resolved to a type

I import the following for this:

import android.content.DialogInterface;

the java code in the example(from android programming unleashed) includes android.app.AlertDialog but importing this results in message: conflicts with a type defined in the same file

Upvotes: 7

Views: 16247

Answers (4)

Piyush
Piyush

Reputation: 18933

You must import your AlertDialog

import android.app.AlertDialog.Builder

instead of

import android.content.DialogInterface;

Also Change

AlertDialog.Builder  alrtDialog = new AlertDialog.Builder(YourActivity.this);

Upvotes: 1

Hariharan
Hariharan

Reputation: 24853

Try to import

import android.app.AlertDialog;

and also if your using this line AlertDialogManager alert = new AlertDialogManager(); remove it and try.

Upvotes: 6

Nambi
Nambi

Reputation: 12042

first check that you have import the corresponding package

import android.app.AlertDialog; and then c

check that you are using your activity instance

AlertDialog.Builder alert = new AlertDialog.Builder(yourActivityname.this);

Upvotes: 3

Timothy T.
Timothy T.

Reputation: 602

You have to import this

import android.app.AlertDialog.Builder

Upvotes: 14

Related Questions