View Single Post
  #2 (permalink)  
Old January 31st, 2009, 12:28 PM
Reto's Avatar
Reto Reto is offline
Wrox Author
Points: 287, Level: 5
Points: 287, Level: 5 Points: 287, Level: 5 Points: 287, Level: 5
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2008
Location: London, United Kingdom
Posts: 61
Thanks: 1
Thanked 7 Times in 6 Posts
Default

Quote:
Originally Posted by sunrain View Post
I am using the latest version of the sample code. Any reasons why?
It looks like a got a bit carried away with a couple of find-replace searches right before I uploaded the sample code. What's happened is I've used getApplicationContext() when I should be passing in the Activity's context.

What you need to do is fix these two lines, replacing getApplicationContext() with this, as shown below:

Code:
LayoutInflater li = LayoutInflater.from(getApplicationContext());
View quakeDetailsView = li.inflate(R.layout.quake_details, null);
    
AlertDialog.Builder quakeDialog = new AlertDialog.Builder(getApplicationContext());
Becomes:
Code:
LayoutInflater li = LayoutInflater.from(this);
View quakeDetailsView = li.inflate(R.layout.quake_details, null);
    
AlertDialog.Builder quakeDialog = new AlertDialog.Builder(this);
Sorry about that, I've got a few updates to the sample code pending that should be available in the next few days.
__________________
Reto Meier

Author, "Professional Android 4 Application Development", Wrox, ©2012, 2010, 2008
@retomeier
Reply With Quote