Wrox Programmer Forums
|
BOOK: Beginning Android Application Development
This is the forum to discuss the Wrox book Beginning Android Application Development by Wei-Meng Lee; ISBN: 978-1-1180-1711-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Android Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2012, 07:58 PM
Registered User
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 2 Dialog Super Class Override

I am working on the Dialog example and I am getting an error I can't find anywhere else in the forums. On the OnClick that looks at the check boxes is giving me these errors:

- The method onClick(DialogInterface, int, boolean) of type new DialogInterface.OnMultiChoiceClickListener(){} must override a superclass
method.
- implements android.content.DialogInterface.OnMultiChoiceClick Listener.onClick

Any help or suggestions would be appreciated. My code is below.

package com.example.dialog;

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

public class DialogProject extends Activity {
CharSequence[] items = {"Google","Apple", "Microsoft" };
boolean[] itemsChecked = new boolean [items.length];

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dialog);


Button btn = (Button) findViewById (R.id.btn_dialog);
btn.setOnClickListener (new View.OnClickListener() {
public void onClick(View v) {
showDialog(0);
}
});
}

@Override
protected Dialog onCreateDialog(int id) {
switch(id) {
case 0:
return new AlertDialog.Builder(this)
.setIcon(R.drawable.ic_launcher)
.setTitle("This is a dialog with some Simple Text")
.setPositiveButton("OK",new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,int whichButton)
{
Toast.makeText(getBaseContext(), "Ok Clicked!", Toast.LENGTH_SHORT).show();
}
})
.setNegativeButton("Cancel", new
DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int whichButton)
{
Toast.makeText(getBaseContext(),"Cancel clicked",Toast.LENGTH_SHORT).show();
}
})
.setMultiChoiceItems(items, itemsChecked,new DialogInterface.OnMultiChoiceClickListener() {

@Override
public void onClick(DialogInterface dialog, int which, boolean isChecked){
Toast.makeText(getBaseContext(),items[which] + (isChecked ? " checked": " unchecked"),
Toast.LENGTH_SHORT).show();
}
}
)
.create();
}
return null;
}
}





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2 -- To Do List -- when to use super.onCreate(icicle);? SteveOliverC BOOK: Professional Android Application Development ISBN: 978-0-470-34471-2 6 January 5th, 2009 10:42 PM
Invoke Events that were declated in a super class Aaron Edwards ASP.NET 2.0 Professional 1 January 2nd, 2008 03:59 PM
Capturing toolbar events inside a dialog class pazzuzu Visual C++ 0 October 13th, 2004 01:35 AM
Page_Load override with base page class nebrown1 BOOK: ASP.NET Website Programming Problem-Design-Solution 1 August 31st, 2003 04:45 AM
Dialog Class pic_az Java GUI 4 June 5th, 2003 03:34 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.