Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 317
M D Avatar asked Dec 19 '13 07:12

M D


People also ask

How do I import AlertDialog?

java file to add alert dialog code to launch the dialog. Modify layout XML file res/layout/activity_main. xml add any GUI component if required. Run the application and choose a running android device and install the application on it and verify the results.

What is dialogue box in Android?

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed. Dialog Design.


3 Answers

You have to import this

import android.app.AlertDialog.Builder

like image 94
Timothy T. Avatar answered Nov 10 '22 20:11

Timothy T.


Try to import

import android.app.AlertDialog;

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

like image 29
Hariharan Avatar answered Nov 10 '22 20:11

Hariharan


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);
like image 32
Nambi Avatar answered Nov 10 '22 20:11

Nambi