displaying a dialog using an activity?

what am i doing wrong here or what do i need to add?

package dialog.com;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.app.Dialog;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class Dialog extends Activity {
    CharSequence [] items = { "google", "apple", "microsoft" };
    boolean [] itemschecked = new boolean [items.length];
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        Button btn = (Button) findViewById(R.id.btn_dialog);
        btn.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
    protected Dialog onCreateDialog(int id) {
        switch(id) {
        case 0:
            return new AlertDialog.Builder(this)
            .setTitle("This is a Dialog with some simple text...")
            .setPositiveButton("ok", new
                    DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog,
                        int whichbutton)
                            "OK Clicked!", Toast.LENGTH_SHORT).show();
                    DialogInterface.OnclickListener() {
                public void onClick(DialogInterface dialog,
                        int whichButton)
                        "cancel clicked!", Toast.LENGTH_SHORT).show();
            .setMultiChoiceItems(itemschecked, new
                    DialogInterface.OnMultiChoiceClickListener() {
                public void onClick(dialoginterface dialog, int which, boolean isChecked) {
                            items[which] + (isChecked ? " checked!":
        return null:



Rename your class to something other than Dialog. Call it CustomDialog or something.

This is example from "Begining Android Application Development" book.

It didn't worked so i added this:

  1. import your.package.name.R;
  2. And delete the last @override, the one for onClick() method. (Just delete annotation, not the method.)
  3. I deleted the line: .setIcon(R.drawable.icon), couldn't fix that.

After this code worked.

Need Your Help

Cannot deploy MVC 4 to server

c# asp.net asp.net-mvc web-deployment

My web application is just a simple web application made in VS 2010 MVC 4 without any code from outside. It's just default application of VS 2010. I have Deluxe Windows Hosting with Plesk. I've never

Inserting an indexed element of array into textbox while in 'edit' mode

html arrays angularjs input

I am making a simple To Do list using AngularJS v1.4.3. Here is a plunkr of my work so far.