Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Mobile Development > BOOK: Beginning Android Application Development
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 30th, 2012, 07:58 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
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;
}
}
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:09 AM.


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