Here a Post, There a Post
Remove that line and replace it with:
ListView list=(ListView)findViewById(R.id.timeline);
list.setAdapter(adapter);
list.setOnItemClickListener(onStatusClick);
That gives control on a click to an onStatusClick object. In there, we need to
get the TimelineEntry corresponding with the click, scan the status to find
the location (if any), and pass that information to StatusMap via
startActivity().
Add the following onStatusClick implementation to Patchy:
private AdapterView.OnItemClickListener onStatusClick=
new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
TimelineEntry entry=timeline.get(position);
Matcher r=regexLocation.matcher(entry.status);
if (r.find()) {
double latitude=Double.valueOf(r.group( 1 ));
double longitude=Double.valueOf(r.group( 4 ));
Intent i=new Intent(Patchy.this, StatusMap.class);
i.putExtra(LATITUDE, latitude);
i.putExtra(LONGITUDE, longitude);
i.putExtra(STATUS_TEXT, entry.status);
startActivity(i);
}
}
};
This requires a few constants to be added to Patchy as well:
public static final String LATITUDE="apt.tutorial.latitude";
public static final String LONGITUDE="apt.tutorial.longitude";
public static final String STATUS_TEXT="apt.tutorial.statusText";
We also need the Pattern that defines the regular expression we are
searching for: